Best way of implementing this in java
So I have this requirments:
A class called Destination
A HashMap called Destinations
The Destination class has an array of objects of the type Door. So
basically I read a "door" from a file, and every door has an attribute
"destination" which tells me which destination it belongs to.
My question is, what's better?:
a) A method in the object that holds Destinations that checks whether the
destination for the new door exists or not in the HashMap Destinations,
and therefore insert that door to its existing Destination or create the
new Destination and then insert the door.
b) Override (?) the add method for the Destinations HashMap and implement
the previous described functionality there.
c) Another way.
Thank you.
No comments:
Post a Comment