Question
A total of four classes are required: netID_Employee An abstract class which the other employee types inherit from netID_HourlyEmployee A netID_Employee whose pay is based
A total of four classes are required:
netID_Employee An abstract class which the other employee types inherit from
netID_HourlyEmployee A netID_Employee whose pay is based on an hourly wage and the number of hours worked
netID_SalaryEmployee A netID_Employee whose pay is based on a yearly salary
netID_CommissionEmployee A netID_Employee whose pay is based on a commission rate and sales amount
UML Diagram for Class netID_Employee
netID_Employee {abstract}
- firstName : String
- lastName : String
- mI : Character
- gender : Character
- employeeNumber : Integer
- fulltime : Boolean
<
mI : Character, gender : Character
employeeNumber : Integer, fulltime : Boolean)
+ setFirstName(firstName : String) : void
+ getFirstName() : String
+ setLastName(lastName : String) : void
+ getLastName() : String
+ setMI(mI : Character) : void
+ getMI() : Character
+ setGender(gender : Character) : void
+ getGender() : Character
+ setEmployeeNumber(employeeNumber : Integer) : void
+ getEmployeeNumber() : Integer
+ setFulltime(fulltime : Boolean) : void
+ getFulltime() : Boolean
+ calculateWeeklyPay() : Double {abstract}
+ annualRaise() : void {abstract}
+ holidayBonus() : Double {abstract}
+ resetWeek() : void {abstract}
+ equals(o : Object) : Boolean
+ toString() : String
What follows is a short description of what each data member represents and what each method does.
firstName: Stores the first (given) name of the netID_Employee.
lastName: Stores the last (family) name of the netID_Employee.
mI: Stores the middle initial of the netID_Employee.
gender: Stores the gender, either M (male) or F (female) (see setGender() below), of the netID_Employee.
employeeNumber: Stores the employee number of the netID_Employee. The employee number must be in the range 10000 to
99999 (inclusive) (see setEmployeeNumber() below).
fulltime: Stores a value indicating whether the netID_Employee is fulltime (true) or part-time (false).
netID_Employee(): This is the class constructor and creates a netID_Employee with the supplied values. The method must
use setFirstName(), setLastName(), setMI(), setGender(), setEmployeeNumber() and setFulltime() to set the
values of the associated data membersthe data members must not be accessed directly.
setFirstName(): Predicate method that sets the value of firstName.
getFirstName(): Predicate method that returns the value of firstName.
setLastName(): Predicate method that sets the value of lastName.
getLastName(): Predicate method that returns the value of lastName.
setMI(): Predicate method that sets the value of mI.
getMI(): Predicate method that returns the value of mI.
setGender(): Predicate method that sets the value of gender. If an invalid value for gender is given (not M or F), it should
default to F.
getGender(): Predicate method that returns the value of gender.
setEmployeeNumber(): Predicate method that sets the value of employeeNumber. If an invalid value is passedone that is less
than 10000 or greater than 99999the method should continuously prompt the user with the message
Bad employee number. Try again.
for another number until an acceptable one is provided.
getEmployeeNumber(): Predicate method that returns the value of employeeNumber.
setFulltime(): Predicate method that sets the value of fulltime.
getFulltime(): Predicate method that returns the value of fulltime.
calculateWeeklyPay(): Abstract method for returning the weekly pay of the Employee. As an abstract method, it should be
declared without an implementation.
annualRaise(): Abstract method for providing an annual raise to the Employee. As an abstract method, it should be declared
without an implementation.
holidayBonus(): Abstract method for returning the holiday bonus of the Employee. As an abstract method, it should be declared
without an implementation.
resetWeek(): Abstract method for resetting the week (e.g., number of hours worked) of the Employee. As an abstract method, it
should be declared without an implementation.
equals(): Overrides Object equals(). Compares the current object (i.e., this) to o. Two netID_Employees are equal if and
only if the values of employeeNumber of the two instances are equal.
toString(): Overrides Object toString(). Returns a string representation of the netID_Employee in the following format:
Employee: Steve A. Rogers (12345), M, fulltime
This method must use getFirstName(), getLastName(), getMI(), getGender(), getEmployeeNumber() and
getFulltime() to return the values of the respective data membersthe data members must not be accessed directly. Note that
gender is given as Male or Female (not M or F) and that status isnt true or false, but rather full time or part-time. The
method should not display anything.
UML Diagram for Class netID_HourlyEmployee
netID_HourlyEmployee extends netID_Employee
- hourlyRate : Double
- hoursWorked : Double
<
mI : Character, gender : Character,
employeeNumber : Integer,
fulltime : Boolean, hourlyRate : Double)
+ setHourlyRate(hourlyRate : Double) : void
+ getHourlyRate() : Double
+ setHoursWorked(hoursWorked : Double) : void
+ getHoursWorked() : Double
+ increaseHours(hours : Double) : void
+ calculateWeeklyPay() : Double
+ annualRaise() : void
+ holidayBonus() : Double
+ resetWeek() : void
+ toString() : String
What follows is a short description of what each data member represents and what each method does.
hourlyRate: Stores the hourly pay rate.
hoursWorked: Stores the number of hours worked.
netID_HourlyEmployee(): This is the class constructor and creates a netID_HourlyEmployee with the supplied values. The
method must call the superclass constructor and must use setHourlyRate() and setHoursWorked() to set the values of these
data members (hoursWorked should be explicitly set to 0)the data members must not be accessed directly.
setHourlyRate(): Predicate method that sets the value of hourlyRate.
getHourlyRate(): Predicate method that returns the value of hourlyRate.
setHoursWorked(): Predicate method that sets the value of hoursWorked.
getHoursWorked(): Predicate method that returns the value of hoursWorked.
increaseHours(): Method that increases hoursWorked by the supplied value. This method must use getHoursWorked() and
setHoursWorked() to get and set the value of hoursWorkedthe data member must not be accessed directly. If hours is
negative the message
Can't increase hours by a negative value. No change.
should be displayed and no change should be made hoursWorked.
calculateWeeklyPay(): Method that returns the weekly pay of the netID_HourlyEmployee. This method must use
getHoursWorked() and getHourlyRate() to calculate the paythe data members must not be accessed directly. If the
number of hours worked is more than 40 than the hourly rate is double for the additional hours. For example, if the hourly rate is
$10/hour and the employee worked 50 hours then the total pay would be: (40 hours $10/hour) + (10 hours $20/hour) = $600.
annualRaise(): Method that increases hourlyRate by 5%. This method must use getHourlyRate() and setHourlyRate()
to get and set the value of hourlyRatethe data member must not be accessed directly.
holidayBonus(): Method that returns a bonus of 40 hours of pay; i.e., 40 hours hourlyRate. This method must use
getHourlyRate() to get the value of hourlyRatethe data member must not be accessed directly.
resetWeek(): Method for setting hoursWorked to 0. This method must use setHoursWorked() to change the value of
hoursWorkedthe data member must not be accessed directly.
toString(): Overrides Employee toString(). Returns a string representation of netID_HourlyEmployee in the following
format:
Employee: Steve A. Rogers (12345), M, fulltime, 0.00 hours, $15.34/hour.
The method must call the superclass version of toString() and use getHoursWorked() and getHourlyRate() to get the
values of hoursWorked and hourlyRate, respectively. The method should not display anything.
UML Diagram for Class netID_SalaryEmployee
netID_SalaryEmployee extends netID_Employee
- salary : Double
<
mI : Character, gender : Character,
employeeNumber : Integer,
fulltime : Boolean, salary : Double)
+ setSalary(salary : Double) : void
+ getSalary() : Double
+ calculateWeeklyPay() : Double
+ annualRaise() : void
+ holidayBonus() : Double
+ resetWeek() : void
+ toString() : String
What follows is a short description of what each data member represents and what each method does.
salary: Stores the salary.
netID_SalaryEmployee(): This is the class constructor and creates a netID_SalaryEmployee with the supplied values. The
method must call the superclass constructor and must use setSalary()to set the value of this data memberthe data member
must not be accessed directly.
setSalary(): Predicate method that sets the value of salary.
getSalary(): Predicate method that returns the value of salary.
calculateWeeklyPay(): Method that returns the weekly pay of the netID_SalaryEmployee; i.e., salary/52 weeks. This
method must use getSalary() to calculate the paythe data member must not be accessed directly.
annualRaise(): Method that increases salary by 5%. This method must use getSalary() and setSalary() to get and set
the value of salary. The data member must not be accessed directly.
holidayBonus(): Method that returns a bonus of 3% of salary. This method must use getSalary() to get the value of
salarythe data member must not be accessed directly.
resetWeek(): For a SalaryEmployee this method has no effect.
toString(): Overrides Employee toString(). Returns a string representation of netID_SalaryEmployee in the following
format:
Employee: Steve A. Rogers (12345), M, fulltime, $75000.00/year.
The method must call the superclass version of toString() and use getSalary to get the value of salary. The method should
not display anything.
UML Diagram for Class netID_CommissionEmployee
netID_CommissionEmployee extends netID_Employee
- rate : Double
- sales : Double
<
mI : Character, gender : Character,
employeeNumber : Integer,
fulltime : Boolean, rate : Double)
+ setRate(rate : Double) : void
+ getRate() : Double
+ setSales(sales : Double) : void
+ getSales() : Double
+ increaseSales(sales : Double) : void
+ calculateWeeklyPay() : Double
+ annualRaise() : void
+ holidayBonus() : Double
+ resetWeek() : void
+ toString() : String
What follows is a short description of what each data member represents and what each method does.
rate: Stores the commission rate.
sales: Stores the amount of sales.
netID_CommissionEmployee(): This is the class constructor and creates a netID_CommissionEmployee with the supplied
values. The method must call the superclass constructor and must use setRate() and setSales() to set the values of these
data members (sales should be explicitly set to 0)the data members must not be accessed directly.
setRate(): Predicate method that sets the value of rate.
getRate(): Predicate method that returns the value of rate.
setSales(): Predicate method that sets the value of sales.
getSales(): Predicate method that returns the value of sales.
increaseSales(): Method that increases sales by the specified amount. This method must use getSales() and setSales()
to get and set the value of salesthe data member must not be accessed directly. If sales is negative the message
Can't increase sales by a negative amount. No change.
should be displayed and no change should be made sales.
calculateWeeklyPay(): Method that returns the weekly pay of the netID_CommissionEmployee; i.e., rate sales. This
method must use getRate() and getSales() to calculate the pay.
annualRaise(): Method that increases rate by 0.2. This method must use getRate() and setRate() to get and set the value
of ratethe data member must not be accessed directly.
holidayBonus(): Returns 0. (CommissionEmployees dont receive holiday bonuses.)
resetWeek(): Method for setting sales to 0. This method must use setSales() to change the value of salesthe data
member must not be accessed directly.
toString(): Overrides Employee toString(). Returns a string representation of netID_HourlyEmployee in the following
format:
Employee: Steve A. Rogers (12345), M, fulltime, 2.70%, 0.00.
The method must call the superclass version of toString() and use getRate() and getSales() to get the values of rate and
sales, respectively. The method should not display anything.
SAMPLE TEST
Creating HourlyEmployee. . .
Creating SalaryEmployee. . .
Creating CommissionEmployee. . .
Bad employee number. Try again. 5
Bad employee number. Try again. 54
Bad employee number. Try again. 543
Bad employee number. Try again. 5432
Bad employee number. Try again. 54321
Employee: Steve A. Rogers (12345), Male, full time, 0.00 hours, $15.34/hour.
Employee: Kitty X. Pryde (54321), Female, full time, $75000.00/year.
Employee: Johnny F. Storm (54321), Female, part-time, 2.50%, 0.00.
Testing for equality. . .
Hourly (12345) and salary (54321) are different!
Salary (54321) and Commission (54321) are the same!
Increasing Hourly's hours worked by -50.
Can't increase hours by a negative value. No change.
Increasing Hourly's hours worked by 50.
Increasing Commission's sales by -150,000.
Can't increase sales by a negative amount. No change.
Increasing Commission's sales by 150,000.
Calculating weekly payouts. . .
Hourly payout: $920.40
Salary payout: $1442.31
Commission payout: $375000.00
Finding total bonus payout. . .
Bonus Payout is $2863.60
Applying annual raises and resetting weeks. . .
Employee: Steve A. Rogers (12345), Male, full time, 0.00 hours, $16.11/hour.
Employee: Kitty X. Pryde (54321), Female, full time, $78750.00/year.
Employee: Johnny F. Storm (54321), Female, part-time, 2.70%, 0.00.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started