From 461171ff469a9db0d1450b0ac9d57434f16c356d Mon Sep 17 00:00:00 2001 From: Vikram Date: Mon, 25 Feb 2019 19:42:37 -0700 Subject: [PATCH] minor changes. Still in progress. --- src/Player.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Player.java b/src/Player.java index 8ff4e2b..8542fd6 100644 --- a/src/Player.java +++ b/src/Player.java @@ -444,6 +444,20 @@ public class Player { public void gameOver(){ System.out.flush(); 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."); + } + } } }