|
Hi there,
If i were to do it, i would create another class with a method run() that returns a integer. Now i can get the main method to create an instance of this class.Create a loop that will call the method run().
public static void main(string Args[])
{
Game myGame=new Game();
while(x==0)
{
myGame.run();
}
}
********
public class Game()
{
public int run()
{
//your code goes here. This code below runs after the game completes
System.out.println("Would you like to play again?" 0 for yes, 1 for no)
int decision=myInput.nextInt(); //remember to import Scanner method
return decision;
}
}
When the method run completes, you decide in the programming logic for it to return either 1 or 0.
So if it's zero, it runs again. Otherwise it stops.
|