Question: Define the Employee abstract superclass from which specific types of Employee's can be derived. This abstract class contains one instance variable; name. This class should
Define the Employee abstract superclass from which specific types of Employee's can be derived. This abstract class contains one instance variable; name.
This class should contain a default constructor.
This class should contain a constructor which can be used to pass in the name of the Employee.
This class should contain the getName() method to retrieve the name instance variable
This class should contain the setName() method to set the name instance variable.
This class should contain an abstract method, getSalary(), which is not defined in this class because determining the salary of an Employee is dependent on the Employee type.
Define two derived classes from the Employee superclass:
The Commission class should be derived from the Employee class The salary for this type of employee is based on a sales commission percentage.
The Hourly class should be derived from the Employee class. The salary for this type of employee is based on a base pay plus tips collected.
Each derived class should contain constructors, which call the constructor of the superclass.
Each class should implement a toString() method to provide a formatted output of the name, as well as the salary based on the Employee type.
Examples:
Commission employee1 = new Commission( "Wendy Smith", 40000, 4 ); Hourly employee2 = new Hourly( "Bruno Hildago", 800, 325 ); System.out.println( employee1 ); may result in an output of Wendy Smith salary is $1600.00 System.out.println( employee2 ); may result in an output of Bruno Hildago salary is $1125.00
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
