OOP Tutorial Week 4: Music and Movie Database

Authors: Ewan Klein
Version: 1.2
Date: 2009-02-11

Overview

This is a simple exercise in using inheritance as part of the process of design and implementation. The goal is to develop a database in which you can record information about CDs and DVDs that you either own or would like to acquire. (If you are so inclined, you could also consider older artifacts, such as video tape, cassette tape, vinyl, etc.).

Task 1

Decide what objects you want to include in your database. Let's assume that it is just CDs and DVDs initially. What information do you want to store about them? Example info for CDs might be:

And for movie DVDs:

Extend each of these lists. At this stage, do not worry about implementation.

Task 2

Sketch out how you might implement a Java class for CDs and DVDs respectively. What instance variables would you need, and what setters and getters?

Also sketch out the code for the database. We will assume that the database holds two lists of objects, one for each of these types. The database class will also have a method for printing out the details of the elements of each list. How would you add information to the list of CDs and DVDs, and how would you delete information? How would you print out the details of each list?

Task 3

You will notice that there is some duplication in code across your two classes for CDs and DVDs. Can you abstract this away into a superclass? What impact would this have on your treatment of the CD and DVD classes? And would it affect your design and implementation for the database class?


OOP Informatics Home