2.2 Example2.1 Inheritance2 Java with Caffeine2.3 Superclasses and Subclasses

2.2 Example

We are going to introduce the basics of inheritance in Java by the following example: Take an Internet shop that offers books as well as CDs. The shop stores the following pieces of information on books:

article number
title
price
author
publisher
ISBN number.

The following is stored on CDs:

article number
title
price
interpreter
list of songs.

When a customer orders articles via the Internet, she wants to see a shopping cart with a list of articles including article number, title, and price. When clicking on the article, she should see the remaining information about the article (for books, the author, publisher, and ISBN number; for CDs, the interpreter and the list of songs).


© Wolfgang Schreiner; February 3, 2005

2.2 Example2.1 Inheritance2 Java with Caffeine2.3 Superclasses and Subclasses