Exercise 6-1. A visual representation of a class, its member fields and methods, and its place in the hierarchy is called a class diagram. There are several accepted methods for drawing a class diagram, but we won't hold you to any of those right now. For this exercise, simply draw a class diagram for a class named vehicle
, listing some member fields and methods that you think that class should have. Then add to your diagram the derived classes car
, boat
, and plane
, and list their fields and methods (remember that all derived classes inherit the fields and methods of their parent class).
Exercise 6-2. You've defined a class as a diagram; now try defining one in code. Define a class Book
, in which a book has a title, author, and ISBN, and the book can be read or shelved. You don't need to fill in the code for any methods you include; simply include a comment in the body, like we did for the Dog
class earlier in the chapter.