Академический Документы
Профессиональный Документы
Культура Документы
}
}
public static void CarryOn(){ // method used to ask user if he wants to play
again
System.out.println("Do you want to play again?"+"\n"+"Y/N"); //message t
o where the user must enter Y or N to play again
String choice = kb.nextLine(); //stores choice in the varible "choice"
if(choice.equalsIgnoreCase("y")){ //if choice is equal to y then true
System.out.println("New Game"+"\n"); //display new game
}
else if(choice.equalsIgnoreCase("n")){ //or if if choice is equal to n
replay = false; //replay = flase which will end the game
}
else{
System.out.println("Inaccurate choice. Ending program"); //else if not
y or n is enter
System.exit(0);
//the game will terminate
}
}
}
//end