Consider following class Certification with following data members Id (int), name (String) ,hours(int),level (String),costPerHr (double). Provide a class StudentCertification that extends Certification. This class has an additional data member rebate (double). Override the calculateFee method so that the total cost is calculated by getting the total for the training hours @costPerHr and applying the rebate (%). E.g. if the costPerHr is 200 and 50 hours training and 0.2 rebate then the calculateFee should return 10000 – 0.2 *10000 = 8000. Provide another sub class ProfessionalCertification that extends Certification. This class no additional data member. It overrides calculateFee method so that total cost is returned as product of hours and cost per hour plus 15% tax of total hours cost. Also ProfessionalCertification implements Extendible Interface. You will also have to provide the implementation of method extend(int duration). For this you need to add the duration to training hours of the certification
public class Certification {
private int id;
private String name;
private int hours;
private String level;
private double costPerHr;
public double getCostPerHr() {
return costPerHr;
}
public int getHours() {
return hours;
}
public void setHours(int hours) {
this.hours = hours;
}
public double calculateFee() {
return hours * costPerHr;
}
}
public class StudentCertification extends Certification {
private double rebate;
@Override
public double calculateFee() {
return super.calculateFee() - rebate * super.calculateFee();
}
}
public class ProfessionalCertification extends Certification implements Extendible {
@Override
public double calculateFee() {
return super.calculateFee() + super.calculateFee() * 0.15;
}
@Override
public void extend(int duration) {
setHours(getHours() + duration);
}
}
Comments
Leave a comment