Reputation:
I need to design a UML class diagram but I have the following problem. The application I am designing consists of a set of objects, let's say cars. What I want to do, is keep a record of all the cars, the days they've been used, etc.. So, I have a car class. Should I have also a CarCollection class? If yes, how should I implement it?
I should keep in mind that I'm not modelling a database.
Thank's!
Upvotes: 2
Views: 3848
Reputation: 73627
Apparently, it's homework:
I need to design a UML class diagram (...).
I should keep in mind that (...)
I'll help you but won't do the work for you. From your narrative, you can deduce the following:
Car
Usage
(with property date_of_use
) Car
with n Usage
This diagram shows the classes of a system that manages one set of cars composed of all the objects of that class. There is no need for an additional collection.
But you could of course add a class Fleet
, with an aggregation of Cars
. Then your system could manage several independent sets of cars : it would comply with the narrative as well, because it could be used to manage the special case of a single set as well.
Upvotes: 2