Results 1 to 3 of 3
  1. #1
    endgame is offline Member
    Join Date
    Jun 2014
    Posts
    7
    Rep Power
    0

    Default ArrayList and object question

    So i have a problem i want to make a menu that allows you to press 1 and then make lets say a Car,

    the code would look like

    Car car = new Car();

    and then add to my list

    cars.add(car);

    if in my menu the person presses 1 again, will they add another car or will it override it



    also: how can i make a menu that doesnt allow you to press option 5(something that requieres you something that should be registered in other options ), untill you registered them?

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,600
    Rep Power
    5

    Default Re: ArrayList and object question

    Quote Originally Posted by endgame View Post
    if in my menu the person presses 1 again, will they add another car or will it override it
    If you program it to do so, then yes. It is up to you how you handle it.

    Quote Originally Posted by endgame View Post
    also: how can i make a menu that doesnt allow you to press option 5(something that requieres you something that should be registered in other options ), untill you registered them?
    Simply set flags (booleans or bit maps entries) that indicate whether the other options have been set. Then check those flags before allowing someone to press option 5.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  3. #3
    endgame is offline Member
    Join Date
    Jun 2014
    Posts
    7
    Rep Power
    0

    Default Re: ArrayList and object question

    Quote Originally Posted by jim829 View Post
    If you program it to do so, then yes. It is up to you how you handle it.
    but what i typed, what would happend



    Quote Originally Posted by jim829 View Post
    Simply set flags (booleans or bit maps entries) that indicate whether the other options have been set. Then check those flags before allowing someone to press option 5.
    gonna try it tnks.

Similar Threads

  1. ArrayList Keeps Repeating The Same Object
    By Morpheus in forum New To Java
    Replies: 6
    Last Post: 03-22-2011, 08:44 PM
  2. Getting value of Object[] in an ArrayList
    By adela in forum New To Java
    Replies: 4
    Last Post: 01-28-2011, 08:13 AM
  3. Replies: 2
    Last Post: 11-16-2010, 05:51 PM
  4. Replies: 3
    Last Post: 03-15-2010, 08:44 PM
  5. Replies: 1
    Last Post: 03-04-2009, 06:14 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
  •