Define an abstract class called staff

Assignment Help JAVA Programming
Reference no: EM131996012

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

Reference no: EM131996012

Questions Cloud

Financed at caribbean target debt-to-equity ratio : Assuming that the project will be financed at Caribbean’s target debt-to-equity ratio, should the company invest in the project?
Expectations for the market and two particular stocks : Consider the following expectations for the market and two particular stocks in two possible equally likely states:
The expected return on the market portfolio : Given that the expected return on the market portfolio is 8% and the risk-free rate is 3%, which projects would you accept and why?
Calculate best-case and worst-case npv figures : Calculate the best-case and worst-case NPV figures.
Define an abstract class called staff : Define an abstract class called Staff with the following fields and methods: Fields: name, id, position representing the name, staff id and the position.
Determine which gasses will diffuse slower : What metric are you using to determine which gasses will diffuse slower? What does molar mass have to do with it? Is there and equation you're referencing?
Relationship between an acid and its conjugate base : Describe the relationship between an acid and its conjugate base. Provide an example of an acid and the corresponding conjugate base?
Perform search on articles about social engineering attacks : Perform a search on the Web for articles and stories about social engineering attacks or reverse social engineering attacks. Find an attack that was successful.
Equilibrium expressions and reaction quotients : Why are pure substances (liquids and solids) not included in equilibrium expressions and reaction quotients?

Reviews

Write a Review

JAVA Programming Questions & Answers

  An array of items that would be used by a small business

Select a task that a program could perform over an array of items that would be used by a small business.

  Implement a client program

Implement a client program with a main method to demonstrate the evolution of the sales tax rates in the 50 US states over the last 10 years. Declare a two-dimensional array of values representing the sales tax rates. Dimension 1 represents the st..

  Constructor that initializes the three automatic properties

Create a class called Date that adds three pieces of information as automatic properties-a   month (type int), a day (type int) and a year (type int).

  Java program that iterates through the integers

Write a Java program that iterates through the integers from 1 to 20, computing the square of each number and writing the information to a file called squares.txt.

  Regular expression that selects lines

Write a regular expression that selects lines containing the html BR tag. The rules for this tag are that, like all html tags, it starts with . In between are the letters b and r in that order

  Inheritance involves the concept of super class

Inheritance involves the concept of super class (parent class) and sub class (derived class). What is a super class in Java? What is a sub or derived class in Java?

  Prepare demo program that implements all of above method

Specify, design, and implement a class that can be used in a program that simulates a combination lock.

  Prepare a demo program

Design, and implement a class that will be used in a program that simulates a combination lock. The lock has a circular knob with the numbers 0 through 39 marked on the edge, and it has a three-number combination, which we will call x,y,z.

  Write a program that gets input for a string

Proper coding conventions required the first letter of the class start with a capital letter and the first letter of each additional word start with a capital

  Write a program to store information on vehicle owners

This type should be used in the program to store information on vehicle owners. The information we need in this situation is the owner's name and age.

  In java programming objects are stored on stack

In java programming Objects are stored on Stack. True/False

  Write a class named java1306cmis141c801 that performs the

write a class named java1306cmis141c801 that performs the following actions.prompt the user for an int between lower

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd