Question
TASK: You want to develop a Java program that will allow you to keep track of a set of employees. In reviewing your employee list,
TASK:
You want to develop a Java program that will allow you to keep track of a set of employees. In reviewing your employee list, you notice that your employees fall into two categories: Salaried and Hourly. The following table shows the information that is stored for each type of employee.
Field | Data Type | Salaried | Hourly |
id | int | X | X |
name | String | X | X |
title | String | X |
|
position | String |
| X |
salary | int | X |
|
hourlyRate | double |
| X |
Create a NetBeans project using the following naming convention: The project name will:
- Start with the assignment prefix, in this case Lab101.
- The prefix is followed by a dash character
- The dash is followed by your last name
- Your last name is followed by your first initial
- Your first initial is followed by your middle initial
- For example, for this assignment my project would be named Lab101LatimerJB
- Note, no student should turn in a project named Lab101-LatimerJB
In this project create three classes named Employee, Salaried and Hourly such that:
- The Employee class contains all of the fields common to both types of entries in your employee list.
- The Salaried class is a subclass of Employee and contains only those fields that are specific to the Salaried entries in your employee list.
- The Hourly class is a subclass of Employee and contains only those fields that are specific to the Hourly entries in your employee list.
- Each of these classes contains all of the normally expected methods. The normally expected methods are:
- At least one constructor that is an overload constructor that includes all of the necessary information to create an instance.
- A getter and setter (accessor and mutator) method for each instance/class variable
- A toString( ) method
- An equals( ) method
- Create your classes so that you can keep track of the
- Total number of Employees
- Total number of Salaried employees
- Total number of Hourly employees
- Note that you determine these totals by counting the number of times the respective constructors have been called.
Create a fourth class named Client that will be used to test your other classes.
In this Client class:
- This class must include the main method
- In the main method
- Create an array named employeeList of type Employee with a length of 10
- Populate the employeeList array with the following records by creating an appropriate instance of either the Salaried or Hourly class for each employee and then add the instance to the array. The employees should be added to the employeeList array in the order that they are listed, i.e. Al should be at index 0, Kelly should be at index 1, etc.
- A salaried employee named Al who is the Manager and is paid $60,000 per year.
- An hourly employee named Kelly who is a Hostess and is paid $25.75 per hour.
- A salaried employee named Peggy who is the CEO and is paid $120,000 per year.
- An hourly employee named Bud who is a Busboy and is paid $15.00 per hour.
- An hourly employee named Marcy who is a Server and is paid $10.00 per hour.
- An hourly employee named Jefferson who is a Cook and is paid $300 per hour.
- Once you have populated the array
- print out the contents of the array using a for loop.
- Hint just use the toString( ) method to print the contents of an entry.
- This loop should print out the contents of every entry in the array including the blank (null) entries.
- Now give everyone in the employeeList array a 25% raise.
- When applying the raises use a loop to step across the array.
- Your code must dynamically determine the type of employee at each array location by using the instanceof operator (i.e. your code should correctly apply raises regardless of the order in which the employees are entered into the array).
- After you have given everyone a 25% raise:
- Print out the contents of the array using a for loop.
- This time do not print the blank (null) entries.
- Your code must dynamically determine if an entry is null and not print out the null entries.
- Finally, explicitly test the equals methods for each of your classes.
- This will require four tests.
- Show at least one test where the equals( ) method returns true and one test where the equals( ) method returns false for the Hourly class.
- Show at least one test where the equals( ) method returns true and one test where the equals( ) method returns false for the Salaried class.
Provide adequate documentation for your code where adequate documentation is defined as follows:
- Each instance or class variable should have a semantically rich name, i.e. the name should tell the reader what the variable represents. The use of semantically rich identifiers can reduce the amount of documentation that needs to be written.
- Each class should include a Java docs header comment block that includes the following:
- Your name using the @author tag
- The date using the @version tag
- A brief description of the class
- Each method should include a Java docs header
- Include inline comments to explain what is happening in your code.
- Be sure to comment the Client class as well as the Employee, Salaried and Hourly classes.
- Be sure to remove any unnecessary comments or code, e.g. the comment templates provided by NetBeans.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started