For this coding challenge you\'ll be asked to create three classes. In this prac
ID: 3919507 • Letter: F
Question
For this coding challenge you'll be asked to create three classes. In this practice challenge, you'll create classes Employee, PartTimeEmp and FullTimeEmp. During the challenge, you'll have to put the three .java files in a zip file. On Linux, the following command will do so: zip -r submit.zip Employee.java PartTimeEmp.java FullTimeEmp.java (In this case the zip file is called submit.zip and is ready to be uploaded to WebCAT. You can call the zip file anything you want but keep the .zip extension.) A practice WebCAT folder is available to allow you to practice this before your actual coding challenge. The focus of this challenge is on inheritance. Make sure to override as required and invoke parent constructors as appropriate. You do not have to validate arguments to methods for this challenge The following class diagram shows the three classes you are to createExplanation / Answer
Employee.java
public abstract class Employee{
private String name, IDNum;
public Employee(String name, String iDNum) {
super();
this.name = name;
IDNum = iDNum;
}
public String getName() {
return name;
}
public String getIDNum() {
return IDNum;
}
double calculateMonthlyPay() {
double pay = getMonthlyPay();
pay -= 0.1 * pay;
return pay;
}
abstract double getMonthlyPay();
abstract String getStatus();
public String toString() {
String returnValue = "IDNum: " + IDNum + " Name: " + name + " Monthly Pay:" + calculateMonthlyPay() +
" Status: " + getStatus();
return returnValue;
}
}
FullTimeEmp.java
public class FullTimeEmp extends Employee{
private double salary;
public FullTimeEmp(String name, String iDNum, double salary) {
super(name, iDNum);
this.salary = salary;
}
@Override
double getMonthlyPay() {
return salary;
}
@Override
String getStatus() {
return "Full Time Employee";
}
}
*PartTimeEmp.java
public class PartTimeEmp extends Employee{
private int hours;
private double hourlyRate;
public PartTimeEmp(String name, String iDNum, double hourlyRate) {
super(name, iDNum);
this.hourlyRate = hourlyRate;
}
public void addToHours(int amount) {
hours += amount;
}
@Override
double getMonthlyPay() {
// TODO Auto-generated method stub
return 0;
}
@Override
String getStatus() {
// TODO Auto-generated method stub
return "Part Time Employee";
}
public double calculateMonthlyPay() {
double pay = hourlyRate * hours;
hours = 0;
return pay;
}
}
**Comment for any further queries.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.