讲解COLT 3、辅导Software Technology、辅导JAVA程序设计、讲解JAVA
- 首页 >> Java编程Software Technology 1
Assignment 2
COLT 3 2018
Due: Week 10 Friday 11:55pm
Due Date: 14/12/2018
Submission and Assessment requirements:
This assignment will be marked out of 60 marks and carries 10 % mark of the overall mark for the
unit. Please check the unit outline for late penalties and resubmissions.
All submissions need to be electronic submissions through Canvas before the due date. Submission
should be one single zip file (A2StudentID.zip) with JAVA projects for all parts, and a short report (word
document). The report should include:
A copy of the source code for each question.
Evidence of testing (Test plan / screen shots of the results obtained at several stages of
the question for each part). (At least 2 test cases should be shown for each question)
Comments on necessary parts of the code.
A short reflective summary on what you have learnt this assignment.
Proper naming conventions.
Important Notes:
1. The requirements for some programming problems are specified clearly, and for some, they are
not specified clearly, and the requirements are somewhat vague. This has been done intentionally
to make it more challenging, and it is expected that you come up with appropriate design strategy
to solve these problems. You may want to refer to the lab activities in the tutorial classes for
guidance on how to attempt each question.
2. Include UML class design wherever needed using ObjectAid a free UML class diagram creation tool
available at http://www.objectaid.com/home
3. General requirements for each program or class submitted are to have a header or block of
comments at the top. The comments should contain your name, question number, part and the
date. Here is an example:
/*******************************
Author: John Smith (u123456)
Assignment_2_Q1_(12/12/2016)
********************************
Part.1: File I/O in Java [15 marks]
The UC Irvine Machine Learning repository contains many datasets for conducting computer science
research. One such dataset is the Haberman’s Survival dataset, available at
http://archive.ics.uci.edu/ml/datasets/Haberman's+Survival . The file “haberman.data” contains survival
data for breast cancer patients in comma-separated value format. The first field is the patient’s age at the
time of surgery, the second field is the year of the surgery, the third field is the number of positive axillary
nodes detected, and the fourth field is the survival status. The survival status is 1 if the patient survived 5
years or longer and 2 if the patient died within 5 years.
Write a Java Console or GUI based application program that reads the CSV file and calculates the average
number of positive axillary nodes detected for patients that survived 5 years or longer, and the average
number of positive axillary nodes detected for patients that died within 5 years. A significant difference
between the two averages suggests whether or not the number of positive axillary nodes detected can be
used to predict survival time. Your program should ignore the age and year fields for each record.
(8 mark): Write the code include appropriate input validation, error and exception handling code.
(3 Marks): Test Plans
(4 mark): Demonstration to Tutor in week 10.
Part.2: Objects and Classes, Inheritance and Polymorphism(10+12+10+13)
1. Create a GUI application with a method that accepts a string as an argument and returns the
number of vowels that the string contains. The application should have another method that
accepts a string as an argument and returns the number of consonants that the string contains. The
application should let the user enter a string, and should display the number of vowels and the
number of consonants it contains.
(6 mark): Write the code include appropriate input validation, error and exception handling code.
(2 Marks): Test Plans
(2 mark): Demonstration to Tutor in week 10.
2. Write a class named Employee that has the following properties.
Name: The Name property holds the employee's name.
IdNumber: The IdNumber property holds the employee's ID number.
Department: The Department property holds the name of the department in which the
employee works.
Position: The Position property holds the employee's job title.
The class should have the following overloaded constructors:
A constructor that accepts the following values as arguments and assigns them to the
appropriate properties: employee's Name, IdNumber, Departmentand Position.
? A constructor that accepts the following values as arguments and assigns them to the
appropriate properties: employee's Name and IdNumber. The Departmentand Position
properties should be assigned an empty string.
A parameter less constructor that assigns empty string to Name, Department and Position
properties, and 0 to IdNumber.
Create three employee objects to hold the following information:
Name idNumber Department Position
Susan Meyers 47899 Accouting Vice President
Mark Jones 39119 IT Programmer
Joy Rogers 81774 Manufacturing Engineer
(7 mark): Write the code include appropriate input validation, error and exception handling code.
(2 Marks): Test Plans and UML Diagram.
(3 mark): Demonstration to Tutor in week 10
3. Person and Customer classes:
Design a class named Person with properties for holding a person's name, address, and telephone
number. Next, design a class named Customer, which is derived from the Person class. The
Customer class should have a property for a customer number and a Boolean property indicating
whether wishes to be on a mailing list. Demonstrate an object of customer class in a simple GUI
application.
(6 mark): Write the code include appropriate input validation, error and exception handling code.
(2 Marks): Test Plans and UML Diagram
(2 mark): Demonstration to Tutor in week 10
4. PreferredCustomer classes:
A retail store has a preferred customer plan where customers can earn discounts on all their
purchases. The amount of discount depends on customer's cumulative purchases in the store and
the business rules for discounts is as follows:
When a preferred customer spends $500, he or she gets a 5 % discount on all future purchases.
When a preferred customer spends $1000, he or she gets a 6 % discount on all future
purchases.
When a preferred customer spends $1500, he or she gets a 7 % discount on all future
purchases. When a preferred customer spends $2000, he or she gets a 10 % discount on all future
purchases.
Design a class called PreferredCustomer, which is derived from the Customer class you created in
No 3. The PreferredCustomer class should have properties for the amount of the customer's
purchases and the customer's discount level. Demonstrate the class in a simple GUI application.
(8 mark): Write the code include appropriate input validation, error and exception handling code.
(2 Marks): Test Plans
(3 mark): Demonstration to Tutor in week 10