|
Is the taxRate for Book the same as for Toy? A good answer might be:Yes---by using an interface, a constant can be used by several classes. This helps keep the classes consistent. | ||
Testing ProgramHere is a tiny program that tests the classes. If you want to run the program, copy and paste all the classes and the interface to a file called Store.java.
The calculateTax() method is only used with objects who's class implements the interface Here is a picture that shows the classes and their objects:
In the picture, clouds represent classes. Arrows with pointed head connect child classes to parent classes. The dotted rectangle represents the interface; a dotted arrow shows which classes implement it. Rectangles represent objects. Arrows with square head connect an object to its class. | ||
QUESTION 13:
|