CST141 Project 7: Chapter 13

Shape and Parallelogram Classes
--or--
Employee, SalesPerson and Executive Classes,
and SalaryConstants Interface


  1. Including a substantive comment statement that describes the class's purpose, as well as substituting your name for the existing @author comment and the assignment due date for the @version comment that already exist at the top of the new class
  2. Entering a substantive comment before each method (including the constructor) to describe its function along with @parameter and @return tags

Employee
superclass to Salesperson and Executive
  • String name (default is "")
  • String address (default is "")
  • double salary
    range: greater than or equal to 0.0
    (default is 0.0)
Salesperson
extends from Employee
implements SalaryConstants
  • int sales
    range: greater than or equal to 0.0
    (default is 0.0)
and Executive
extends from Employee
implements SalaryConstants
  • (no instance variables)
—Write both the Salesman and Executive subclasses—
  1. The class should have one constructor that takes three arguments, one for each of its attributes, and passes those values to the set methods
  2. A set method for each of the three instance variables; follow validation rules for the salary attribute (see above) and throw an Exception for invalid data
  3. A get method for each of the three instance variables
  4. An abstract method getAdditionalIncome() of type double
  5. Method getTotalSalary() of type double that returns the sum of the salary attribute and the return value of the getAdditionalIncome() method (see SalesPerson and Executive class descriptions below) of its subclasses
  6. Method toString() returns a "string representation of an Employee object with values preceded by descriptive labels as follows: (a) each of the three instance variables; and (b) the return value from the getTotalSalary() method
  1. The class should have two constructors: (a) one that takes no arguments and passes the default values to the second constructor via the this reference; and (b) another that takes four arguments, one its own sales attribute and the three others for its superclass; it passes the three arguments to the superclass' constructor and passes the sales argument to to its own set method
  2. A set method for the sales instance variable; follow validation rules in the set method (see above) and throw an Exception for invalid data
  3. A get method for the sales instance variable
  4. Method getAdditionalIncome() of type double that "implements" the abstract method from superclass Employee and  returns a salesperson's commission which is calculated by multiplying the sales attribute times the sales commission rate constant that comes from the SalaryConstants interface (see below)
  5. There is no toString() method since output for the commission is handled in the toString() method of the superclass
  1. The class should have two constructors: (a) one that takes no arguments and passes the default values to the second constructor via the this reference; and (b) another that takes three arguments which it passes to the superclass constructor
  2. Method getAdditionalIncome() of type double that "implements" the abstract method from superclass Employee and returns a executive's bonus which is calculated by multiplying the salary attribute from the superclass Employee times the bonus rate constant that comes from the SalaryConstants interface (see below)
  3. There is no toString() method since output for the bonus is handled in the toString() method of the superclass
  1. Including a substantive comment statement that describes the class's or interface's purpose, as well as substituting your name for the existing @author comment and the assignment due date for the @version comment that already exist at the top of each new class
  2. Entering a substantive comment before each method (including the constructor) to describe its function along with @parameter, @return and @throws tags