user1627772
user1627772

Reputation:

UML diagram collection of objects

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

Answers (1)

Christophe
Christophe

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:

  • a class Car
  • a class Usage (with property date_of_use)
  • association of 1 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

Related Questions