go to previous page   go to home page   go to next page highlighting

Answer:

The class is completed below.


Using a Constant

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 ;
  }
}

QUESTION 12:

Why must calculateTax() be made public?


go to previous page   go to home page   go to next page