iLab 5 of 7: Inheritance

iLAB OVERVIEW Scenario and Summary The Objective Of the lab is to take the UML Class diagram and enhance last week’s Employee class by making the following changes:
l. Create a derived class called Salaried that is derived from employee.
2. Create a derived class called Hourly that is derived from Employee.
3 Create generalized input methods that accept any type Of Employee or derived Employee Object 4. Create generalized output methods that accept any type Of Employee or derived Employee Object 5. Override the base class calculatePay() method. 6. Override the displayEmployee() method. i LAB STEPS
STEP 1 : Understand the UML Diagram
Analyze and understand the object UML diagram, which models the structure of the program • There are two new Employee derived classes (1) Salaried and (2) Hourly that are derived from the Employee class • The Employee class contains a new attribute employeeType and a new constructor that accepts as an argument the assigned employee type • Both the Salaried and the Hourly classes override only the CalculateWeeklyPay method of the Employee class (note, this 's the method without any parameters) • The Salaried class has one attribute "managementLevel" that has possible values from MIN MANAGEMENT LEVEL to MAX MANAGEMENT LEVEL and a BONUS PERCENT. • The Salaried class has a default constructor and parameterized constructor that accepts all the general employee information plus the management level. • The Hourly has a wage attribute, which represents the hourly wage that ranges from MIN WAGE to MAX WAGE, an hours attributes, which represents the number of hours worked in a week that ranges from MIN HOURS to MAX Hours, and a category attributes that accepts string values • The Hourly class has a default constructor and parameterized constructor that accepts all the general employee information plus the hours and wage value • The Presentation Tier contains two new classes (1) The Employee input class and the EmployeeOutput class • The Employee input class contains three static methods (1) CollectEmployeelnformation, which accepts any type of Employee object as n argument; (2) CollectHourlylnformation, which accepts on y Hourly objects as an argument, and (3) CollectSalariedlnformation, which accepts only Salaried objects as an argument • The EmployeeOutput class contains two methods (1) DisplayEmployeelnformation, which accepts any Employee type as an argument and (2) DisplayNumberObjects method • Al the access specifiers for the Employee attributes are changed to protected and are depicted with the "#" symbol. 1. Modify the Employee Class a. modify the Employee attributes to be protected. b. Delete the iEmployee interface class, and remove the reference from the Employee class. 2. Create the Salaried Class a. Create the Salaried classes, ensuring to specify that the Salary class inherits from the Employee class. b. For each of the constructors listed in the Salaried class, ensure to invoke the appropriate base class constructor and pass the correct arguments to the base class constructor. This will initialize the protected attributes and update the numEmployees counter. c. Note: The valid management levels are 0, 1, 2, and 3, and should be implemented as a constant. d. Override the calculatePay method to add a 10 percent bonus for each of the management levels (i.e., bonus percentage = managementLevel * .10). The bonus percentage should be implemented as a constant.
e. Override the displayEmployee() method to add the management level to the employee information. 3. Label Title a. Create the Hourly classes, ensuring to specify that the Hourly class inherits from the Employee class.For each of the constructors listed in the Hourly class, ensure to invoke the appropriate base class constructor and pass the correct arguments to the base class constructor. This will initialize the protected attributes and update the numEmployees counter. b. The valid category types are "temporary", "part time", and "full time". c. The provided hours must be more than 0 hours and less than 50 hours, and the limits should be implemented as constants.The provided wage must be between 10 and 75, and the limits should be implemented as constants. d. Override the calculatePay method by multiplying the wages by the number of hours. Override the Employee setAnnualSalary method and set the annual salary by multiplying the weekly pay by 50. Override the displayEmployee() method to add the category to the hourly employee information. 4. Create at least one Employee, Hourly, and Salaried employee. For each object created, display the number of employees created. For each object created, write statements to exercise each of the public methods For each object created, invoke the object's displayEmployee() method to display appropriately the employee's information.
Powered by