Description

For this activity you will implement encapsulation and inheritance in a simple but concrete example. A software business needs your help to design an employee class that includes the following attributes:

  • employee ID (empID),
  • employee name (name),
  • employee pay rate (payRate),
  • employee hours (hours),
  • employee extended pay (extendedPay),
  • employee counter (empCounter).

The business currently hires information technology employees in the form of computer programmers as well as accounting employees. You will design a superclass Employee and the two subclasses InfoTech and Accounting. The Employee class will contain several types of attributes. See the UML diagram for the specifications.

Program Specifications

Employee Class:

  • The following attributes are entered directly by the user: name, payRate, hours.
  • The extendedPay attribute is calculated as: (payRate * hours).
  • The static attribute empCounter will be incremented each time an Employee object is added.

During each add process, capture the value of empCounter and store it in the non-static attribute of empID.

InfoTech and Accounting Classes:

The InfoTech class will contain the private string variable progLanguage specifying in which programming language the employee is most skilled, and the Accounting class will contain the private Boolean variable glAccess that specifies whether the employee should have access to the general ledger. Both of those attributes will be input by the user.

Other:

  • Create separate classes for: Employee, InfoTech, and Accounting.
  • Include a main() method to use the classes for this assignment.
  • Each class will contain appropriate constructors, set, and get methods.
  • The superclass Employee will contain a toString method that outputs a message indicating a general employee has been established (hard-coded as text) and will indicate the employee ID, name, pay rate, hours, and extended pay.

Each subclass will contain a toString method that outputs the employee type (hard-coded as text) and the value of each attribute from the superclass and from the class.

Program Execution:

  • First, using a main() method, create an Employee object to create a general employee and call its toString() method.
  • Next, create at least two InfoTech and two Accounting objects varying the attributes of each and call the toString() methods for each object calling its class's toString() method.
  • Finally, create a new reference to an Employee object and individually point it to each of your existing objects one-by-one calling the toString() method polymorphically using the Employee reference.

NOTE: The attribute values for each object instance can be passed as hard-coded values.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.