2. The StateTaxableWorker class inherits from the TaxableWorker class. This clas
ID: 3530491 • Letter: 2
Question
2. The StateTaxableWorker class inherits from the TaxableWorker class. This class adds attributes for the state name and the state tax rate (ie. 0.05). An explicit value constructor must be provided to set the three values of the base class plus the values for the state name and state tax rate. A mutator method must be provided to change the value of the state tax rate. The base class workerInfo method must be overridden to include all the base class worker information plus the state name and state tax rate information. The base class taxWithheld method must be overridden to include the base class tax withheld plus the state tax withheld (gross pay * state tax rate).Explanation / Answer
//you didnt post base class, so some assumptions made
public class StateTaxableWorker extends TaxableWorker{
private String StateName;
private double StateTax;
//you need to change the first 3 parameter to the types and names of the base class
public StateTaxableWorker(someType whatever1,someType whatever2, some Type whatever3,String name,double tax){
super(whatever1, whatever2,whatever3);
StateName=name;
StateTax=tax;
}
void setStateTax(double tax){StateTax=tax;}
void setStateName(String name){StateName=name;}
double getStateTax(){return StateTax;}
String getStateName(){return StateName;}
double taxWithheld(){
return getGross()*StateTax; //assumes that getGross is method of accessor of base class
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.