The video store example has six classes at the moment:
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's a summary of the responsibilities of each class:
Tracks name, address, and phone number. Records payments and charges and keeps an account balance.
Keeps a list of titles. Finds available videos.
Represents a rental transaction. Records duration, calculates charges, marks video as out, processes the return.
Represents a reservation of a title. Records customer and date, marks video as reserved.
Keeps a list of videos, finds available video. Knows charges for this title.
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.
Click the Quiz link below to identify responsibilities and collaborators in the course project.
Video Store - Quiz