Question: Assignment 9 Revised 9/2019 Inheritance, Polymorphism Employee Class Chapter 11 discusses superclasses, subclasses, polymorphism, dynamic binding, and the ArrayList class. You will create a superclass,

Assignment 9 Revised 9/2019 Inheritance, Polymorphism Employee Class

Chapter 11 discusses superclasses, subclasses, polymorphism, dynamic binding, and the ArrayList class. You will create a superclass, a subclass, and a driver class in 3 separate java files. In the driver class, you will create objects demonstrating polymorphism & dynamic binding. The objects will be added to an array list.

Please do this in Java please, add comments so it's easy to understand and read so I know how to be able to do it myself.

I've had the problem of people copying and pasting answers from other versions of the question on here so please do not just copy it.

Please explain what is happening in the assignment.

A class named Employee should include the following:

Employee first name, last name, phone number

No-arg 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

No-arg 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 (dollar sign, comma separated, 2 decimals).

*Note: for those already familiar with Java programming, please keep this simple: try/catch, exceptions, GUI, etc. Please use only the concepts discussed up to this point.

Before starting this lab, be sure to refer to the How to Submit Assignments document in eLearn for proper documentation, indention, naming conventions, etc. Points may be deducted if submitted incorrectly.

REMINDER: Any sources you use besides the textbook, class demo files, or the instructor must be documented in your program with details such as the scope of help received & URL.

Required project name: LastnameFirstname09 Required package name: chap11 Required class names: as noted above

Your program should look similar to this sample output (user input in green):

Employee's first name: Jerry Employee's last name: Simpson Employee's phone (937-555-1212): 937-226-7890 Shift (1-day or 2-night): 4 Shift number is 1 or 2. Please try again: 2 Pay rate per hour: 20.12345 Hours worked this period: 40.000123

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,207.41, Name: Don Griffith

Phone: 937-222-1234 Shift Worked: 2 Pay Rate: $18.75 Hours Worked: 40.00 Total Pay for Period: $1,125.00, Name: Chuck Banner

Phone: 937-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 (one point unless indicated otherwise):

All classes are defined exactly as indicated in the assignment and are in 3 separate .java files.

Appropriate visibility modifiers and datatypes are used (3 pts).

No-arg constructors and overloaded constructors in subclasses use the super( ) keyword with appropriate parameters (2 pts).

The toString in the subclass uses super() to access the toString in the superclass (2 pts).

Properly demonstrate polymorphism, dynamic binding, & casting (if necessary) (3 pts).

ArrayList holds the objects created, is fully functional, & displays in a user-friendly manner (2 pts).

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.

Your program was exported correctly, compiles, & runs.

You follow standard coding conventions (e.g. variable names, indentation, comments, etc.).

File name, global comment, citations, etc. as indicated on How to Submit Assignments (Course Overview).

Helpful Notes:

Data fields should always use the private access modifier so they can only be changed through the mutator/setter methods. This is called encapsulation and is a major part of Java. Do not use the protected modifier.

Although Java automatically provides a default constructor if none is explicitly defined, it is a good idea to always include the constructor with no parameters. This gives the programmer more control over default values. Constructors should use public modifier.

In constructors of subclasses, always use the statement super( ) to invoke the appropriate constructor in the superclass.

Validation & formatting code is more appropriately created in the methods of the class instead of in the main method of the driver. You can use NumberFormat class or DecimalFormat class to format to currency.

To prevent errors when you override a method in the superclass, you use the override annotation @Override.

If user enters invalid choice, the program does not terminate. The program terminates only when the user chooses to quit.

To display ArrayList objects, you can use a foreach loop, a for loop, or implicitly/explicitly call the toString or mor simply just print the name of the ArrayList.

Reread the assignment and run the sample output to confirm all requirements have been met.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!