Forums Register Login

How to choose the right Collection?

+Pie Number of slices to send: Send
Hi

I have small project to be implemented in Java, which, expected the management of a parking.
The project has a class abstract Vehicle, whence derive three classes: Car, Motorcycle, Heavy Vehicles;
the cost estimated time for the 3 types of vehicles are: 2€ for Cars, 1€ for Motorcycle and 5€ for H.V.
In addition, in class Ticket will be stored the arrival time of the customer and the characteristics of his vehicle.
Finally, in the class Parking(which provides 80 places available), here it should be added the various types of vehicles.

Now, I though of using an Collection, as Set.. So that they can not, two Vheicle with same license plate.

You like what you would do?
+Pie Number of slices to send: Send
I don't see the license plate and its uniqueness having anything to do with the problem. The parking area has a fixed number of spots that you can fill, right? What data structure in Java allows you to allocate space for a known number of things? Seems to me the simplest and most straightforward option should do it.
+Pie Number of slices to send: Send
 

Junilu Lacar wrote:I don't see the license plate and its uniqueness having anything to do with the problem. The parking area has a fixed number of spots that you can fill, right? What data structure in Java allows you to allocate space for a known number of things? Seems to me the simplest and most straightforward option should do it.



Bhe, maybe you should manage the insertion of the vehicles in the parking through license plate, otherwise in which element you recognize the customer?

+Pie Number of slices to send: Send
When I go into a parking garage, I get a ticket from an attendant or ticket machine. The gate opens, I go in, I park my car, and go about my business for however long it takes. To get out of the garage, I have to first present my ticket to the attendant or insert it into another machine. I am informed of and pay the parking fees based on the time I exit and the information encoded on the ticket. Nowhere during this transaction does my license plate come into play; only the Ticket is needed. If you need some sort of unique indentifier, it would be for the Ticket, not the Vehicle. Does that make sense?
So you made a portal in time and started grabbing people. This tiny ad thinks that's rude:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1058 times.
Similar Threads
construtor in abstract class
about polymorphic page 95 of k&b
changing vector from GUI events
static int not incrementing, constructor not called.
casting a reference
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 17:50:12.