Você está na página 1de 2

MIS 333K Homework 2: OOP and

Inheritance
Write an Employee class that keeps data attributes for the following pieces of information:
Employee name
Employee number
Next, write a class named ProductionWorker that is a subclass of the Employee class. The ProductionWorker
class should keep data attributes (properties) for the following information:
Shift (use an enum for this)
Hourly pay rate
Hours worked this week
The workday is divided into two shifts: day and night. Create an enum that has the values Day and Night and use
that enum in a property to store which shift that the employee works. Your ProductionWorker class should have a
ValidateShift method that should only allow the user to select day or night.
Once you have written the classes, write a ProcessProdWorker method that creates an object of the
ProductionWorker class and prompts the user to enter data for each of the objects data attributes. Create a
separate static validation class to make sure the user enters valid values for pay rate and hours. Store the data in the
object and then use the objects properties to retrieve it and display it on the screen. You should also display this
workers total pay for the week. Total pay = hourly rate * hours worked. You may not do any calculations on the
ProcessProdWorker method. This calculation MUST be performed on the ProductionWorker class, but do not
store the total pay on the class. (i.e., you should NOT have a property for total pay.)
Next, write a ShiftSupervisor class that is a separate subclass of the Employee class. Shift supervisors earn a
salary and a yearly bonus if their shift meets production goals. A shift supervisor does not receive hourly wages. The
ShiftSupervisor class should have a property for the annual salary and a property for the annual production bonus
that a shift supervisor has earned.
Write a second method called ProcessSupervisor that will create an object of the ShiftSupervisor class and
prompt the user to enter data for each of the objects data attributes. Use your validation class to make sure the user
enters valid values for annual salary and bonus. Store the data in the object and then use the objects properties to
retrieve it and display it on the screen. You should also display this supervisors total annual pay. You may not do any
calculations on the ProcessSupervisor method. Annual pay = salary + bonus. This calculation MUST be performed
on the ShiftSupervisor class. Store the annual pay on the class so it may be retrieved again.
Your main method should prompt the user to select a type of worker and then call the ProcessProdWorker or
ProcessSupervisor method based on that selection. You can make a design decision about how this selection
process should work, but the program should not crash if the user enters something other than the expected input.
Programming Standards
All dollar outputs should be formatted with a $ and two decimal places
Make sure to include the code that will keep the console window open so that we can see the outputs.
All other programming standards should be followed.
o The name of your project should be LastName_FirstName_HW2
o All variable names should be easy to understand related to the problem
o All variable names should start with a data type prefix
o Code should be consistently indented and aligned
o Code should be commented throughout
o Code should have white space to help the reader visually separate the parts of code (use your discretion)
o Code should have a comment block header at the top of your main class (see HW1 for specifics)
Submit a .zip file of your project on Canvas. You can submit as many times as you need to before the deadline.
We will grade the last version you submit.

Você também pode gostar