Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

Question: Task 1: Value

In this task, you are required to provide the definition of a class called Student, which represents a typical (but a very limited) university student. Each student has a name (which consists of a string of characters) and a unique student identification (ID) number (consisting of a string of exactly six numerical digits).

You are also required to define a class called TestStudent, which will be used to perform a number of test used to among other things, verify the correctness of the Student class.

In order to maintain the uniqueness of the student ID, your program will need to check that any new IDs supplied by the user is not the same as any of the existing student IDs.

Following are a list of specifications of the Student class:

• Two fields name and id representing the student name and the student ID respectively as described above

• Get and set methods for each field (getName(), getId(), setName(), setId())

• A toString() method that returns a string description of a given student object

• An isValidId() method which accepts a string representing a possible new student ID as an argument and returns a boolean value (true or false) indicating whether the new ID satisfies the structural requirements of the student ID or not

• A IdExists() which accepts a string argument representing a possible new student ID and returns a boolean value indicating whether the new ID is already being used by another student or not

Your TestStudent class should be able to perform the following functions:

• Create an ArrayList object of Student objects called studentList, using the student data stored in a text file named students.txt(you should create this file such that it stores the student name and ID of several students initially - one line per student)

• Allow the user to add as many new Student objects as the user requests to the ArrayList ensuring that each student has a unique student ID

• When the user has finished adding new students to the list, the program will override the students.txt file such that it includes the data relating to the new students as well as the original ones

• Ability to display a full list of students as well as just the existing student IDs when necessary

Ensure that the program is appropriately documented throughout and thoroughly tested to demonstrate its correct operation.
You need to submit java and class files, a short discussion to explain the logic on how the problem has been solved, and sample output (for detail please see marking criteria and presentation below).

Task 2: Value 12 marks

In this task, you are required to provide complete class definitions and then create instances of various classes and use methods to perform various tests.

(a) Define an abstract class called Staff with the following fields and methods:

• Fields: name, id, position representing the name, staff id and the position of a staff member in an organisation. Encapsulation should be used to protect these fields against intentional or accidental, direct modification

• Constructors: a no-args/default constructor, and an overloaded constructor to initialise the fields to appropriate values when the instances of the class are created

• Methods: a toString() method to print a string representation of the objects, get and set methods to provide access to each of the three fields

(b) Define a subclass of the Staff class called FullTimeStaff with the following additional field and methods:

• Field: researchArea,a string variable representing the research are of the staff member. Again, encapsulation should be used to protect this field against intentional or accidental, direct modification

• Constructors: a no-args/default constructor, and an overloaded constructor to initialise the fields to appropriate values when the instances of the class are created

• Methods: a toString() method to print a string representation of the objects, additional get and set methods as required to provide access to the field

(c) Define a subclass of the Staff class called PartTimeStaff with the following additional field and methods:

• Field: timeFraction representing the time fraction of a part-time staff member. This would be a number between 0.1 and 1.0. Again, encapsulation should be used to protect this field against intentional or accidental, direct modification

• Constructors: a no-args/default constructor, and an overloaded constructor to initialise the fields to appropriate values when the instances of the class are created

• Methods: a toString() method to print a string representation of the objects, additional get and set methods as required to provide access to the field

(d) Define another subclass of the Staff class called CasualStaff with the following additional field and methods:

• Field: hours representing the number of hours that the casual staff member works at the organisation. Again, encapsulation should be used to protect this field against intentional or accidental, direct modification

• Constructors: a no-args/default constructor, and an overloaded constructor to initialise the fields to appropriate values when the instances of the class are created

• Methods: a toString() method to print a string representation of the objects, additional get and set methods as required to provide access to the field

(e) Finally, define another class called TestStaff with a main() method to perform necessary testing for the classes defined in the previous sections. In the main method, write the code to: (1) create an ArrayList object to store references to Staff objects; (2) open a text file named staff.txt (available on interact resources), which contains data relating to staff members, create FullTimeStaff, PartTimeStaff and CasualStaff objects based on the first field in each row in the file ("full", "part", or "casual"); (3) add these objects to the ArrayList; and (4) test various methods of the objects using loop(s) and methods as necessary, including the code to:

• Repeatedly display a menu of five options (1, 2, 3, 4 and 5) such that

• Option 1 will display details of only full-time staff

• Option 2 will display details of only part-time staff

• Option 3 will display details of only casual staff

• Option 4 will display details of all staff

• Option 5 terminate the program

Ensure that the program is appropriately documented throughout and thoroughly tested to demonstrate its correct operation.

You need to submit java and class files, a short discussion to explain the logic on how the problem has been solved, UML diagram, and sample output (for detail please see marking criteria and presentation below).

Rationale: This assignment has been designed to allow students to test and demonstrate their ability to apply inheritance and aggregation patterns in the design and implementation of programs (learning outcome 3);

• interpret design requirements expressed in Unified Modelling Language (UML) (learning outcome 2);

• apply inheritance and aggregation patterns in the design and implementation of programs (learning outcome 3);

• manipulate simple file operations using java; (learning outcome 3);

• use object-oriented techniques and Java resources to develop small applications consisting of a number of classes (learning outcome 5);

Information related to above question is enclosed below:

Attachment:- staff.rar

Java, Programming

  • Category:- Java
  • Reference No.:- M92833663
  • Price:- $25

Priced at Now at $25, Verified Solution

Have any Question?


Related Questions in Java

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

Retail price calculatorwrite a java program that asks the

Retail Price Calculator Write a JAVA program that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: (If an item's wholesale cost is 5. ...

Can someone help me please with those question1what is the

Can someone help me please with those question 1:what is the best data type for student id datatime,currency,number,decimal 2:which relationshipis preferable? one to one,one to many,many to many 3:if you add table A's pr ...

Assessment database and multithread programmingtasktask 1

Assessment: Database and Multithread Programming Task Task 1: Grade Processing University grading system maintains a database called "GradeProcessing" that contains number of tables to store, retrieve and manipulate stud ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Solving 2nd degree equationsbull write the following java

Solving 2nd degree equations • Write the following Java methods • boolean real-sols(double a, double b, double c): it returns true if the 2nd degree equation ax2 + bx + c has real solutions • double solution1(double a, d ...

Can someone kindly help me to consider whether java

Can someone kindly help me to consider whether Java provides the facility of operator overloading? If it does, may you kindly describe how overloading operators can be accomplished? If not, may you kindly describe why yo ...

Operating systems assignment -problem 1 sharing the bridgea

Operating Systems Assignment - Problem 1: Sharing the Bridge A new single lane bridge is constructed to connect the North Island of New Zealand to the South Island of New Zealand. Farmers from each island use the bridge ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Assignment - java program using array of objectsobjectives

Assignment - JAVA Program using array of objects Objectives - This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details - For this assignment, you are required to develop a Menu ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As