Answered step by step
Verified Expert Solution
Question
1 Approved Answer
import java.util.Date; public class HourlyEmployee { private double wageRate; private double hours; //for the month public HourlyEmployee() { super(); wageRate = 0; hours = 0;
import java.util.Date; public class HourlyEmployee { private double wageRate; private double hours; //for the month public HourlyEmployee() { super(); wageRate = 0; hours = 0; } public HourlyEmployee(String theName, Date theDate, double theWageRate, double theHours) { super(theName, theDate); if ((theWageRate >= 0) && (theHours >= 0)) { wageRate = theWageRate; hours = theHours; } else { System.out.println("Fatal Error: creating an illegal hourly employee."); System.exit(0); } } public HourlyEmployee(HourlyEmployee originalObject) { super(originalObject); wageRate = originalObject.wageRate; hours = originalObject.hours; } public double getRate() { return wageRate; } public double getHours() { return hours; } public double getPay() { return wageRate*hours; } public void setHours(double hoursWorked) { if (hoursWorked >= 0) hours = hoursWorked; else { System.out.println("Fatal Error: Negative hours worked."); System.exit(0); } } public void setRate(double newWageRate) { if (newWageRate >= 0) wageRate = newWageRate; else { System.out.println("Fatal Error: Negative wage rate."); System.exit(0); } } public String toString() { return (getName() + " " + getRate().toString() + " $" + wageRate + " per hour for " + hours + " hours"); } private String getName() { // TODO Auto-generated method stub return null; } public boolean equals(HourlyEmployee other) { return (getName().equals(other.getName()) && getRate().equals(other.getRate()) && wageRate == other.wageRate && hours == other.hours); }
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