Question
Java: Design two subclasses of EmployeeSalariedEmployee and HourlyEmployee. A salaried employee has an annual salary attribute. An hourly employee has an hourly pay rate attribute,
Java: Design two subclasses of Employee…SalariedEmployee and HourlyEmployee. A salaried employee has an annual salary attribute. An hourly employee has an hourly pay rate attribute, an hours worked attribute, and an earnings attribute. An hourly employee that works more than 40 hours gets paid at 1.5 times their hourly pay rate. You will decide how to implement constructors, getters, setters, and any other methods that might be necessary.
1. (20 points) Draw a UML diagram for the classes.
2. (80 points) Implement the classes, and write a test program that creates a salaried employee and two hourly employees. One of the hourly employees should have hours worked set to less than 40 and one should have hours worked set to more than 40. The test program should display all attributes for the three employees. To keep things simple, the employee classes don’t need to do any editing.
public class Employee
{
private int empID;
Address address;
Name name;
Date date;
public Employee()
{
}
public Employee(int empID)
{
this.empID = empID;
}
public int getEmpID()
{
return empID;
}
public void setEmpID(int empID)
{
this.empID = empID;
}
public Address getAddress()
{
return address;
}
public void setAddress(Address address)
{
this.address = address;
}
public Name getName()
{
return name;
}
public void setName(Name name)
{
this.name = name;
}
public Date getDate()
{
return date;
}
public void setDate(Date date)
{
this.date = date;
}
}
Step by Step Solution
3.39 Rating (149 Votes )
There are 3 Steps involved in it
Step: 1
Employeejava import javautilDate public class Employee private int empID private Address address private Name name private Date date public Employee public Employeeint empID thisempID empID public int ...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