Results 1 to 3 of 3
  1. #1
    infernocy is offline Member
    Join Date
    Apr 2012
    Posts
    15
    Rep Power
    0

    Default a collection of Vehicles

    Hallo i have a three classes , Abstract class Vehicle , concrete subclass of Vehicle Car and the Depot class(Vehicles Database) - i have an Gui with the name DepotAdmin with a private method SetupDepot which is where a depot is setup and at least 10 Vehicles are added to the depot .

    my question is what is the best way to store those Vehicles in the Depot class , at the moment i am using arrayList , if i create car from car class and put it the Depot would be ok , or it will be better to use arrays ?

    Thanks

  2. #2
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    6

    Default Re: a collection of Vehicles

    which collections will "be better" depends on your needs. do you need no duplicates, fast iteration, fast deleting, sorting etc. in general an arraylist is ok, but tell if you have some special requirements.

  3. #3
    infernocy is offline Member
    Join Date
    Apr 2012
    Posts
    15
    Rep Power
    0

    Default Re: a collection of Vehicles

    ok i will write some more info so you understand better . i have some more classes the concrete subclass of car which is rentableCar and rentablecar implements the interface rentable and a Date class .Cos of the Vehicle being abstract all of the fields are transferred to car and all the fields are transfered again to rentablecar All of the dates are created from the date class
    The depot class has two fields Depot Name and A collection of Vehicles where at the moment i have this private arrayList <Vehicle> vehicleList . The methods of depot are Add vehicle , find vehicle by make , remove vehicle , rent vehicle and return vehicle --

    The only place the date of the return is recorded is in the rentablecar class so i need to connect the depot with the rentablecar class to get the rent Vehicle method working , can i create a method that adds 10 vehicles inside the depot class like a tester ?
    Last edited by infernocy; 04-13-2012 at 12:24 PM. Reason: change some words

Similar Threads

  1. Collection
    By ShitalJain in forum New To Java
    Replies: 1
    Last Post: 06-25-2011, 11:56 AM
  2. Collection Help
    By spartan in forum New To Java
    Replies: 2
    Last Post: 03-18-2011, 10:18 AM
  3. Help me on Collection
    By kathir0301 in forum New To Java
    Replies: 1
    Last Post: 12-03-2010, 12:08 PM
  4. collection
    By D.Calladine in forum New To Java
    Replies: 1
    Last Post: 12-02-2010, 03:36 PM
  5. help for collection api
    By javastuden in forum New To Java
    Replies: 3
    Last Post: 02-24-2010, 12:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •