Java
Develop a Java program that uses:
Inheritance constructs
overriding superclass methods
invoking super class methods
accessing superclass instance variables
abstact classes and methods
Polymorphism
Container operations, access all elements
Prep Readings:
Absolute Java, Chapters 1 – 9.
Project Requirements:
We are going to develop a program that implements inheritance to process employees in an organization. The program will consist of the following classes: Employee, HourlyEmployee, SalariedEmployee, CommissionedEmployee and Company and CompanyTester.
The Employee Class
This is an Abstract class designed to represent an Employee in a company.
Instance Variables.
Employees Name
Employee id number
Static Variable – int nextIDNum – starts at 1000 and is used to generate the next Employee’s IDNum
Methods
Constructor – sets all instance fields from parameters.
Constructor – default constructor, sets all instance field to a default value.
Access and mutator methods for all variables. NOTE Mutator method for IDNum should use the static variable nextIDNum.
computePay – Abstract method that computes employee pay.
toString method – returns a neatly formatted string containing the s name and id number
The HourlyEmployee Class
Subclass of Employee Class
Instance Variable
employees hourly rate of pay
hours worked during current week
Methods
Constructor – sets all instance fields from parameters.
Default Constructor – sets all instance fields to a default value.
Access and mutator methods for instance variable.
Overwritten computePay method
1. pay calculation
1. <= 40 hours – rate * hours
2. > 40 hours – rate * 40 + (hours above 40 * rate * 1.5).
toSting – toString method – returns a neatly formatted string containing the employees name, id number (where have you see this before) and hourly rate of pay.
The SalariedEmployee Class
Subclass of Employee Class
Instance Variable – weekly salary
Methods
Constructor – sets all instance fields from parameters.
Default Constructor – sets all instance fields to a default value.
Accessor and mutator methods for instance field.
Overwritten computePay method – Returns weekly salary
toString method – returns a neatly formatted string containing the employees name, id number and weekly salary
The CommissionedEmployee Class
Subclass of SalariedEmployee
Instance Variable
weeklysales
commission percentage
Methods
Constructor – sets all instance fields from parameters.
Default Constructor – sets all instance fields to a default value.
Accessor and mutator methods for instance fields.
Overwritten computePay method
pay calculation
add commission to weekly salary
commission = weeklysales * commission percentage.
toString method – returns a neatly formatted string containing the employees name, id number, weekly salary and commission
The Company Class
Holds and manages all the employee objects.
Instance fields
Name of company
A container (ArrayList or Array) to hold the abstract classes employee objects. ArrayList are not covered until Chapter 14 but they are fairly simple to use if you’d like to use them in this project.
Methods
Constructor – sets the instance field from parameter and creates the container.
Default Constructor – sets the instance field to a default value and creates the container
Add an employee to the container
Get an employee by employee Id
Get the number of employees in the company
Get the total payroll for the company assuming all employees work a 40 hour work week.
toString method that returns a neatly formatted string the company name and each employees information (employees name, id number and weekly pay (assume 40 hour work week).
CompanyTester Class
Creates a Company Object
Adds several employees of each type to the Company class.
Tests all the methods in all the classes, either directly or indirectly.
Create 2 UML Class Diagram for this project.
Design Version – completed prior to coding the project to assist with coding.
Final Version – completed after the coding that accurately represents the final version of the code.
All instance variables, including type.
All methods, including parameter list, return type and access specifier (+, -);
No need to include the CompanyTester in the UML diagrams. Refer to the UML Distilled pdf on the content page as a referene for creating class diagrams.
PLACE THIS ORDER OR A SIMILAR ORDER WITH US TODAY AND GET A GOOD DISCOUNT 🙂