/* method for humanTurn private static int humanTurn(String

/* * MCIS 5103 Project 1 * Name: Oluwafemi Samuel Oyekunle * Student Id: 999993740 * E-Mail: [email protected] */  import java.util.Scanner;   // Creating a class name for assignment pigGamepublic class PigGame { public static Scanner pig = new Scanner(System.in); public static void main (String args) { // calling the pigGame method   PigGame(); } // My pigGame method private static void PigGame() { System.out.println(“Welcome, lets play the pig game”); System.out.println(“——————————-“); //declaring variables String human = displayHumanName(); /*displayHumanName method takes a string input from  human, saves it in the human variable and returns the human’s name */ String computer = “Computer”; int humanScore = 0;      // First instance score is zero int computerScore = 0;  // First instance score is zero // while loop to check if human score is up to 100 or not while (humanScore < 100 && computerScore < 100) { // The displayCurrentScore method show scores cummulatively each time a player rolls the dice. displayCurrentScore(human,humanScore,computer,computerScore); /*The humanTurn method will create the logic for accumulating  * points for human and asking if human wants to hold or roll*/ int humanTurnScore = humanTurn(human); humanScore += humanTurnScore; displayCurrentScore(human,humanScore,computer,computerScore); int computerTurnScore = computerTurn(computer); computerScore += computerTurnScore; } //This method displays current results as long as none of the players have reached 100 displayFinalResult(human,humanScore,computer,computerScore); } //The displayHumanName method private static String displayHumanName() { System.out.println("Please Enter your name"); return pig.nextLine(); } // The displayCurrentScore method private static void displayCurrentScore(String human,int humanScore, String computer, int computerScore) { System.out.println(human +":" + humanScore + "    " + computer +":" + "  " + computerScore); } //The method for humanTurn private static int humanTurn(String playerName) { System.out.println(playerName +"'s turn"); int turnScore = 0; boolean playerWantsToRoll = true; //while loop for human's turn to roll dice. while(playerWantsToRoll) { int randomDiceRoll = (int)(6*Math.random()) + 1; System.out.println(playerName + " rolled a"+ " " + randomDiceRoll); if (randomDiceRoll == 1) { //message System.out.println("Sorry " + playerName + " you got no point for this turn" ); return 0; } turnScore += randomDiceRoll; //message System.out.println(playerName + " now have" +" " + turnScore + " points"); System.out.println("Do you want to keep rolling dice? r = roll h = hold"); char playerChoice = pig.next().charAt(0); if (playerChoice == 'r') { playerWantsToRoll = true; } else if (playerChoice == 'h' ) { playerWantsToRoll = false; } } System.out.println(playerName + " decides to hold with " + turnScore + " points"); return turnScore; } //The method for computerTurn private static int computerTurn(String playerName) { System.out.println(playerName +"'s turn"); int turnScore = 0; boolean computerRolls = true; //while loop for computer's turn to roll dice. while(computerRolls) { int randomDiceRoll = (int)(6*Math.random()) + 1; System.out.println(playerName + " rolled a"+ " " + randomDiceRoll); if (randomDiceRoll == 1) { //message when computer rolls a 1 System.out.println("Sorry " + playerName + " you got no point for this turn" ); return 0; } turnScore += randomDiceRoll; //message System.out.println(playerName + " now have" +" " + turnScore + " points"); if (turnScore >= 20) { computerRolls = false; } } System.out.println(playerName + ” decides to hold with ” + turnScore + ”                            points in this round”); return turnScore; } // The displayGameResult to check winner method private static void displayFinalResult(String human, int humanScore,String computer,int computerScore) { if (humanScore > computerScore) { System.out.println(“*************************************************”); System.out.print(“The final score is “); displayCurrentScore(human,humanScore,computer,computerScore); System.out.println(“Congratulations ” + human + ” , ” + ” you won!”); System.out.println(“**********************************************”); }else { System.out.println(“**********************************************”); System.out.print(“The final score is “); displayCurrentScore(human,humanScore,computer,computerScore); System.out.println(“Congratulations ” + computer + ” , ” + ” you won!”); System.out.println(“*************************************************”); } } }