• Post Reply Bookmark Topic Watch Topic
  • New Topic

Hi guys I have a school project can you help me out how to go back from previous segment of my code.  RSS feed

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

When you say add another item to salesman, do you mean where xxx is new:


or

have a new Item say


 
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gia Mata wrote:...
////What should I put here guys??? I wanna go back to the previous menu wherein I R means return to add more items to selected salesperson.

First: Welcome to JavaRanch, Gia.

Second: Please read the UseCodeTags (←click) page; especially the bit about long lines. I actually tried putting code tags in for you, but your lines are so long (and your indenting is also bad) that it actually made the thread harder to read than before.

[Edit: I notice that Ulf's done it for you anyway; but do you see that it now doesn't fit on the screen? That's because your lines are too long.
You can edit your post via the 'Edit' button to break them up if you want.]

Third: To answer your actual question: Put all that code inside a larger loop which you don't break out of until the user enters something that causes you to quit.
Unfortunately, what you'll then end up with is a gigantic block of hellishly indented code; so an alternative is to take most of that "inputting" stuff out of main() and put it in a separate method, then call that method from a loop.

But even better still is probably to StopCoding (←click) and write down what you need to do in English (or your native language) before you write anything else in Java.

It looks to me like you just started coding and have now run into a roadblock, and that's not usually a good way to work.

You may also find the UserInput page worth reading, because user input is notoriously difficult to get right the first time you try it.

HIH

Winston
 
Sheriff
Posts: 4293
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you stop coding and write down what you want to do, you may get something like: display menu, get user input, act on input, etc. These often translate into separate methods or even classes. Try separating your functions into methods and see if that helps.
 
Ranch Hand
Posts: 355
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It isn't also advisable to use continue; inside your while loop. What do you want to achieve with that?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!