Question: You will create a superclass, a subclass, and a driver class. In the driver class, you will create objects demonstrating polymorphism & dynamic binding. The
You will create a superclass, a subclass, and a driver class. In the driver class, you will create objects
demonstrating polymorphism & dynamic binding. The objects will be added to an array list.
A class named Employee should include the following:
Employee first name, last name, phone number
Default constructor and at least 1 overloaded constructor
Accessor & mutator methods
Overridden toString method to display the employees full name and phone number
A class named ShiftWorker should include the following:
Employee shift number. The workday is divided into two shifts: day & night. Day shift is
represented by the number 1 and night shift is represented by the number 2. The night shift
workers get paid 1.5 times their rate of pay. Example: if Sam works day shift and earns
$20/hour, he would earn $30/hour on night shift.
Employee pay rate per hour and hours worked
Default constructor and at least 1 overloaded constructor
Accessor & mutator methods
Method to calculate employees total pay for the period (pay rate * shift differential * hours
worked)
Overridden toString method to display the employees full name, phone number, shift
number, hourly pay, hours worked, and total pay for the period according to their shift. Format
the hourly pay and total pay for currency. Format the hours worked to 2 decimal places.
A class with a main method that runs the program & includes the following:
Get user input either in the console or with dialog boxes for employee name, phone number,
shift, hourly pay rate, and hours worked this period.
Create an instance of a ShiftWorker object & initialize the object with the user input using the
class setter methods.
Create at least one more instance of a ShiftWorker object & initialize the object(s) for a different
employee. This time, initialize the object(s) using the overloaded constructor.
To demonstrate polymorphism & dynamic binding, create at least 1 more instance of an object
using Employee or Object as the declared type and ShiftWorker as the actual type. Initialize the
object(s) using the overloaded constructor.
Create an ArrayList named employeeList of the objects created in your program. Then display
the size of the ArrayList and the elements. Reminder: you may need to cast objects.
Required validation & formatting: shift should be limited to only 1 or 2. Hours worked should be 0 or
greater & formatted to 2 decimal places. Pay rate & total pay must be formatted to currency.
Before starting this lab, be sure to refer to the How Grades are Determined document in eLearn for
proper file name, documentation, naming conventions, etc. Points may be deducted if submitted
incorrectly. Before submitting in the dropbox, please reread the entire assignment to confirm all
requirements have been met.
Recommended name for new Java project: FirstnameLastname_Lab09
Recommended name for package: chap11Inheritance
Your program should look similar to
Employee's first name: Jerry
Employee's last name: Simpson
Employee's phone (777-555-1212): 777-226-7890
Shift (1-day or 2-night): 4
Shift number is 1 or 2. Please try again: 2
Pay rate per hour: 20.10
Hours worked this period: 40
Employee List contains 3 elements:
[
Name: Jerry Simpson
Phone: 937-226-7890
Shift Worked: 2
Pay Rate: $20.10
Hours Worked: 40.00
Total Pay for Period: $1,206.00,
Name: Don Griffith
Phone: 777-222-1234
Shift Worked: 2
Pay Rate: $18.75
Hours Worked: 40.00
Total Pay for Period: $1,125.00,
Name: Chuck Banner
Phone: 777-898-4567
Shift Worked: 1
Pay Rate: $25.00
Hours Worked: 41.75
Total Pay for Period: $1,043.75
]
You will be graded according to the following rubric (each item is worth one point):
All classes are defined exactly as indicated in the assignment.
Appropriate visibility modifiers and datatypes are used.
Default/no-arg constructors and overloaded constructors in subclasses use the super()
keyword with appropriate parameters.
Properly demonstrate polymorphism, dynamic binding, & casting (if necessary).
ArrayList holds the objects created, is fully functional, & displays in a user-friendly
manner. The size of the ArrayList is also displayed.
The object(s) initialized with user input uses class setters.
At least one object created & initialized using an overloaded constructor.
Validation & formatting as required.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
