Hi
I tried making a simple implementation of a guessing game. If you guess high or low, it keeps outputting in the System console, despite my stop method. Input and output appear OK, it's getting it to stop that's the problem.
Any advice welcome. BTW, eventually I'd implement this fully in Greenfoot. For now, I just want to run a simple Java implementation that produces a result.
public void guessGame(){
String first_name;
int ranNum = Greenfoot.getRandomNumber(10) + 1;
int guess = 0;
guess = Integer.parseInt(JOptionPane.showInputDialog("Guess your number between 1 and 10 here"));
while (guess != ranNum) { //while the guess is wrong, do what follows
if (guess < ranNum){
System.out.println("your guess was too low!");
Greenfoot.stop();
}
else if (guess > ranNum){
System.out.println("your guess was too high!");
Greenfoot.stop();
}
else {
System.out.println("you got it!");
Greenfoot.stop();
}
}
