Reputation: 3
I am unsure how to represent the following 3 in a class diagram or whether some of they should be represented at all in a class diagram. I have gone through the UML spec but am still confused on the ones below:
1) 2) 3) are all in a another class named Vehicle
, how would you represent each of them in a class diagram.
1) List<Car> cars = new ArrayList<>(20);
2) Cars car1;
3) import com.esoxjem.carmanual.Cars;
4) What if a cars object is created in the Car
class itself. How would that be represented?
If someone could draw example of the above situation it would be incredibly helpful.
Upvotes: 0
Views: 113
Reputation: 1789
I am not able to do a comment but maybe there is a mix between Car, a class modeling a car, and cars which is a list of Car, but Cars is not a class. Is that right ?
if this case, the first one is an association between Vehicule and Car with a cardinality *, the second is an association between Vehicule and Car with a cardinality 1.
As already said, "import com.esoxjem.carmanual.Cars - this seems like it is refering to the Cars object in Item 2 above."
Then it is needed to choose if association are "simple" association or a composite. Please see section 9.5.3 of UML 2.5 (march 2015)
Upvotes: 0
Reputation: 954
I am making some assumptions here as it seems some details have been omitted in the question (there is a mentioning of a spec, what is included in this spec? Are there more objects?). It would be useful to post further information that may help in providing a correct answer.
Based on the information present, the list of three items can be interpreted as follows:
List<Cars>
- this could represent something like a car dealership (as an example), maybe the list contains the cars sold at this dealership?Cars
- a car objectimport com.esoxjem.carmanual.Cars
- this seems like it is refering to the Cars object in Item 2 above.So the way I see it there are two objects (CarDealership & Car). The cardinality between CarDealership and Car would be one-to-many (1-*).
Upvotes: 0