next up previous
Up: Unit 08 Previous: Inheritance or composition? (optional)

Exercises

Exercise 08.1 Extend the class Book (Exercise 3.1), by defining other classes:

For each of the above classes, define the constructor and suitably redefine the method for the visualization of the object. Describe the hierarchy of classes.

Exercise 08.2 Write an example program for the classes defined in Exercise 8.1, that realizes the following operations.

  1. for a first book, read the title, the authors, the course, and the faculty adopting it, and store this information in an object;
  2. show the information about the first book;
  3. for a second book, read the title and the authors, and store them in a suitable object;
  4. read the topic of the second book, and create a third object of type novel;
  5. show the information about the two objects used to create the second book;
  6. read the price of the first book and update the corresponding object accordingly;
  7. show the information about the first book, including the price.


next up previous
Up: Unit 08 Previous: Inheritance or composition? (optional)