This week's giveaway is in the Spring forum.
We're giving away four copies of Microservices Testing (Live Project) and have Chris Love & Andres Sacco on-line!
See this thread for details.
Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
    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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

back to main menu. Help!!

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
hi there
I am currently doing a DVD Rental System that when the user runs the program, he gets to choose from the menus. My problem is that when the user enters a menu and customizes for example a client, I don't know how to go back for the main menu. This is what I have done so far;

This is the main menu ;



Then the user chooses for example the number 1 (Clients) and the following menu is then shown:



I don't know what do I have to write in case 6 so that the main menu will be shown again. Can somebody please help?? Thanks
 
Bartender
Posts: 563
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Let's call what you've written so far, menu(). The purpose of menu() is to get the user's input to control program flow. Any time you want to get the user's input, you'd call method menu() and either get the user's menu choice in an instance variable or have the method menu() return the user's choice as a token of some kind. Since you have multiple menus (apparently), and I don't know what those look like, I'm not sure how those will work in, but you could use the same kind of control as suggested below, but have different menu() methods that change different usersChoice variables.

Then, a general form of your program could be (there are many other possibilities, this is a suggestion):



Write your menu design down on paper, code a small parts of it, starting with a main() method that compiles and runs, then compile/test/fix/validate/repeat, and come back when you need help.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Please UseOneThreadPerQuestion

Continue in https://coderanch.com/t/566407/java/java/return-main-menu . I'm closing this thread.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic