The class is completed below.
The constant taxRate
is used in the calculateTax()
method just as if it had been defined in the Toy
class.
Also, it can be used in methods
of the class other than those listed in the interface.
The calculateTax()
method must be made public.
class Toy extends Goods implements Taxable { protected int minimumAge; public Toy( String des, double pr, int min) { super( des, pr ); minimumAge = min ; } public String toString() { return super.toString() + "minimum age: " + minimumAge ; } public double calculateTax() { return price * taxRate ; } }
Why must calculateTax()
be made public
?