• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

restart

 
jp staff
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to figure out how to restart a program after I have already run through it. For instance, Would the user like to start over again, where should I place this code and should I use a Loop of some sort
Thanks Jpre
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you need to provide more info to get this answered. Is it a GUI? How is it started? What does it do?
 
jp staff
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
He is my code in a nutshell, after it goes through everything I want to beable to ask the user if it would like to go through the process again

[This message has been edited by Cindy Glass (edited September 12, 2001).]
 
Dave Vick
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JP
Just put the entire working part of the main in a loop. Here it is in a do loop:

you'll need to declare the int variable doOver in the code above where the loop starts.
One point though, from a design stand point. You're collecting the information from the user in inputDialogs but then you show the results on the command line. That is a little hard to follow and some users might get confused. It might be better to do it all one way or the other - all on the command line or all with dialog boxes.
hope that helps you out
------------------
Dave
Sun Certified Programmer for the Java� 2 Platform
[This message has been edited by Dave Vick (edited September 10, 2001).]
 
jp staff
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks dave that helps me out a lot, I am very new to java, and still think in terms of c, to take input from the command line from the user, How do I do that. My book dosen't go into to much detail. Thanks Jp
 
Dave Vick
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JP
Here this should give you good start on it.
declare this before the actual loop:
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
At the bottom of the loop, instead of the dialog use this:

If you need more let me know

------------------
Dave
Sun Certified Programmer for the Java� 2 Platform
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic