OO Concepts   «Prev  Next»
Lesson 3 Responsibilities and collaborators
Objective Describe the responsibilities and collaborators for the video store example.

Video Store Example using Responsibilities and Collaborators

The video store example has six classes at the moment:
  1. Customer,
  2. Inventory,
  3. Rental,
  4. Reservation,
  5. Title, and
  6. Video.

Each class has certain responsibilities, such as tracking or recording information or making calculations. We distinguish between a title and a video because there may be several copies of a popular title in stock. Each video may be out or available, for example. Customers query about titles, though: They do not care whether copy 7 is available or not, as long as at least one copy is available.

Here is a summary of the responsibilities of each class:
  1. Customer: Tracks name, address, and phone number. Records payments and charges and keeps an account balance.
  2. Inventory: Keeps a list of titles. Finds available videos.
  3. Rental: Represents a rental transaction. Records duration, calculates charges, marks video as out, processes the return.
  4. Reservation: Represents a reservation of a title. Records customer and date, marks video as reserved.
  5. Title:Keeps a list of videos, finds available video. Knows charges for this title.
  6. Video: Tracks status (out, reserved, available).

You can see in these descriptions that classes collaborate to get things done.
The Rental class marks the video as out (rented), but that information is kept in the Video class, so on that responsibility, Video is a collaborator.
When Inventory finds an available video, it does so by getting the Title class to collaborate. This kind of interaction is vital to any object-oriented application.

Video Store - Quiz

Click the Quiz link below to identify responsibilities and collaborators in the course project.
Video Store - Quiz