• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to choose the right Collection?

 
Ranch Hand
Posts: 74
MySQL Database Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
MySQL Database Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Police line, do not cross. Well, this tiny ad can go through:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic