• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to choose the right Collection?  RSS feed

 
manu lix
Ranch Hand
Posts: 74
Java MySQL Database Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Junilu Lacar
Sheriff
Posts: 11493
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
manu lix
Ranch Hand
Posts: 74
Java MySQL Database Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

 
Junilu Lacar
Sheriff
Posts: 11493
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!