Update Player.java
changes to how the game ends
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
public class Player {
|
public class Player {
|
||||||
|
|
||||||
private String name = "Taipan";
|
private String name = "Taipan";
|
||||||
@@ -211,7 +213,21 @@ public class Player {
|
|||||||
public void gameOver(){
|
public void gameOver(){
|
||||||
System.out.flush();
|
System.out.flush();
|
||||||
System.out.println("Game over");
|
System.out.println("Game over");
|
||||||
System.exit(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
public boolean playAgain(){
|
||||||
|
Scanner input = new Scanner(System.in);
|
||||||
|
System.out.println("Would you like to play again? Y/N");
|
||||||
|
while(true){
|
||||||
|
String response = input.nextLine();
|
||||||
|
if(response.equalsIgnoreCase("Y")){
|
||||||
|
return true;
|
||||||
|
}else if(response.equalsIgnoreCase("N")){
|
||||||
|
System.exit(0);
|
||||||
|
}else{
|
||||||
|
System.out.println("That is not a valid input.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user