Question
For this project you will write a complete Java program that manages various types of employees. You will be modeling a hierarchy of employee classes
For this project you will write a complete Java program that manages various types of employees. You will be modeling a hierarchy of employee classes as shown in the image below:
The design issues are key in this project. Make sure to follow any explicit direction given below, but several details are left to you to decide. Find the appropriate place to define particular elements of your solution. Make appropriate use of the toString method.
The underlying issues of this project are inheritance and polymorphism. Allow each class to represent itself as much as possible / appropriate.
The Employee Hierarchy
Employees in our fictitious company are represented by the class hierarchy given above.
The StaffMember class is abstract, and is used to store common elements at appropriate levels. For example, StaffMembers all have first and last names, and StaffMember Volunteer Salaried Hourly Executive StaffDemo an id number (int). They also have a pay rate (double).
The constructors of all staff member classes should accept parameters representing the id number, first name, last name, and pay rate (in that order). The pay rate can also be modified using a separate setter method called setPayRate().
All StaffMember objects can be paid, although this concept is undefined (abstract) at the StaffMember level.
Specific staff members are represented by Volunteer, Salaried, Hourly, and Executive objects. Volunteers receive no monetary compensation. All other StaffMember objects should manage a financial pay rate, which is interpreted differently depending on the type of employee. Assume that all employees are paid once per month.
The payment for Salaried employees should be interpreted as their annual salary. So the pay method should return their salary divided by 12. An Executive gets paid their salary plus any bonuses accumulated. A bonus is a one-shot deal once paid, the bonus value goes back to zero. The bonus amount for each executive is 1% of his/her annual salary. The Executives may also accrue additional bonus amounts in a given month.
The payment for an Hourly employee should be interpreted as their per-hour pay rate. Hours are accumulated and payment is made accordingly. Once paid, accumulated hours go back to zero. The company policy is that the Hourly employees work for a minimum of 80 hours a month. These employees can also choose to work overtime and accrue more hours.
Appropriate functionality must be added to various classes to represent their processing. For example, the Executive employee will need an addBonus() method that accepts a double representing a bonus to be added to their current bonus (they could get more than one bonus in a given month). Hourly employees will need an addHours() method that accepts a double value to add to the accumulating hours worked.
Feel free to augment the definition of these classes as you see fit with other data and methods, but they are not intended to be realistic representations of employees in a real company.
Driver Class
You will also create a class called StaffDemo that includes the main() method to exercise the various functionality. You will read the information about the staff members from a file. Sample file:
The first line includes the number of employee records. You may assume that the files that you would read from would be of the exact same format as shown above.
The information read should be used to create staff member objects that will be stored in an array of Staff Members. Write a method called createStaff() to achieve this.
Include a method in the StaffDemo class called payAll() that will pay all employees by printing out their name and current payment.
Sample Output:
James Gosling (Volunteer): $0.00
Grace Hopper (Executive): $7,083.35
StaffMember Volunteer Salaried Hourly Executive StaffDemo StaffMember Volunteer Salaried Hourly Executive StaffDemoStep 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