• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

code for an if statement

 
Chris Lavery
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have created a menu and i want to create a loop through the menu any time a new entry is made so that it scans to check if the entry is already in the menu, if this is true then i want it to remove the entry from where it is in the menu and place it at the top. can anybody please suggest some possible code for this
 
Stephen Boston
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What kind of menu? Can you supply some code to show us what you have?
 
Kenneth Albertson
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there, Chris. Still working on this problem? A number of people made helpful suggestions when you asked the same question a couple of days ago. If you still don't know where to start, perhaps you need to go right back to the beginning. Tell us what classes you think that you need, and then the two fundamental things that you need to know about each class:
  • What do they need to know, ie fields, and
  • What do they need to do, ie methods.
  • Central to this problem is the design of a data structure to hold the menu items. The previous discussion suggested an array or a list. I suggest that you use an array, it will be an easier approach for a beginner.

    I also suggest that you do the problem in two parts. Start by ignoring the requirement to avoid duplicate entries, because that is the hardest part. Get everything else working, and by then you should have enough understanding of what you are doing to tackle the removal of duplicate entries as well.

    BTW, a quick refresher of How To Ask Questions On Java Ranch might be useful as well.
    [ October 13, 2005: Message edited by: Kym Thompson ]
     
    Henry Wong
    author
    Marshal
    Pie
    Posts: 21016
    78
    C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Another issue is, if you don't understand the answers, ask for clarification. Don't just ignore the answers.

    Henry
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic