Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(Employee Hierarchy) In this chapter, you studied an inheritance hierarchy in wh

ID: 3729252 • Letter: #

Question

(Employee Hierarchy) In this chapter, you studied an inheritance hierarchy in which class BasePlusCommissionEmployee inherited from class CommissionEmployee. However, not all types of employees are CommissionEmployees. In this exercise, you'll create a more general Employee superclass that factors out the attributes and behaviors in class CommissionEmployee that are common to all Employees. The common attributes and behaviors for all Employees are fi rstName, I astName, socialSe-curityNumber, getFirstName, getlastName, getSocialSecurityNumber and a portion of method toString. Create a new superclass Employee that contains these instance variables and methods and a constructor. Next, rewrite class CommissionEmployee from Section 9.4.5 as a subclass of Employee. Class CommissionEmployee should contain only the instance variables and methods that are not declared in superclass Employee. Class CommissionEmployee's constructor should invoke class Employee's constructor and CommissionEmployee's toString method should invoke Employee's toString method. Once you've completed these modifications, run the CommissionEmployee Test and BasePlusCommis-sionEmployee Test apps using these new classes to ensure that the apps still display the same results for a CommissionEmployee object and BasePlusCommissionEmployee object, respectively re to search 5 6 7 8

Explanation / Answer

Since you have not mentioned the language of your preference, I have provided the code in Java.

Employee.java

*********************************

class Employee {

   private String firstName, lastName, socialSecurityNumber;

   public Employee(String firstName, String lastName, String socialSecurityNumber) {

       super();

       this.firstName = firstName;

       this.lastName = lastName;

       this.socialSecurityNumber = socialSecurityNumber;

   }

   /**

   * @return the firstName

   */

   public String getFirstName() {

       return firstName;

   }

   /**

   * @return the lastName

   */

   public String getLastName() {

       return lastName;

   }

   /**

   * @return the socialSecurityNumber

   */

   public String getSocialSecurityNumber() {

       return socialSecurityNumber;

   }

   /* (non-Javadoc)

   * @see java.lang.Object#toString()

   */

   @Override

   public String toString() {

       return "Employee [firstName=" + firstName + ", lastName=" + lastName + ", socialSecurityNumber="

               + socialSecurityNumber + "]";

   }

}

CommissionEmployee.java

*********************************

public class CommissionEmployee extends Employee{

   // declare CommissionEmployee fields here that are not declared in Employee class

  

   public CommissionEmployee(String firstName, String lastName, String socialSecurityNumber) {

       super(firstName, lastName, socialSecurityNumber);

       // TODO Auto-generated constructor stub

   }

  

   // define methods here that are not defined in Employee class

   /* (non-Javadoc)

   * @see java.lang.Object#toString()

   */

   @Override

   public String toString() {

       return super.toString();

   }

}

****NOTE: Kindly provide the exisiting implementation of BasePlusCommissioneEmployee and CommissionEmployee so that I can provide your the exact post implementation of CommissionEmployee.java. Right now, i have put proper comments of where to include the CommissionEmployee fields and methods.