Select Page

Inheritance – Programming Challenge 1


Employee and ProductionWorker Classes


 

nanadwumor

May 27, 2023
Java-Programming-Challenge-Employee-and-production-worker-classes-

Employee and ProductionWorker Classes

Design a class named Employee. the class should keep the following information in fields :

  • Employee name
  • Employee number in the format XXX-L, where each X is a digit within the range 0-9 and the L is a letter within the range A-M.
  • Hire date

Join other Subscribers on our YouTube channel and enjoy daily programming tutorials.


Write one or more constructors and the appropriate accessor and mutator methods for the class.

Next, write a class named ProductionWorker that extends the Employee class. The ProductionWorker class should have fields to hold the following information:

  • Shift (an integer)
  • Hourly pay rate (a double)

The workday is divided into two shifts: day and night. The shift field will be an integer value representing the shift that the employee works. The day shift is shift 1 and the night shift is shift 2.

Write one or more constructors and the appropriate accessor (getter) and mutator (setter) methods for the class. Demonstrate the classes by writing a program that uses a ProductionWorker object.

Recommended


Solution

Employee Class

ProductionWorker Class

WorkerDemo

Output

Java-Programming-Challenge-Employee-and-production-worker-classes-Output

Share this article


You May Also Like…

double data type in Java

double data type in Java

The double data type is also a floating point number. It is called double because it has a double-precision decimal...

The print and println methods in Java

The print and println methods in Java

The print() and println() methods are Java's predefined methods used to display text output on the console. These...

float data type in Java

float data type in Java

It is a floating point number. It has single precision data type. It stores a floating point number of 7 digits of...