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.
class Toy extends Goods implements Taxable { int minimumAge; Toy( String des, double pr, int min) { super( des, pr ); minimumAge = min ; } void display() { super.display() ; System.out.println( "minimum age: " + minimumAge ); } public double calculateTax() { return price * taxRate ; } }
The calculateTax()
method must be made public.