Respuesta :
Answer:
(1)
public int getPlayer2Move(int round)
{
 int result = 0;
Â
 //If round is divided by 3
 if(round%3 == 0) {
   result= 3;
 }
 //if round is not divided by 3 and is divided by 2
 else if(round%3 != 0 && round%2 == 0) {
   result = 2;
 }
 //if round is not divided by 3 or 2
 else {
   result = 1;
 }
Â
 return result;
}
(2)
public void playGame()
{
Â
 //Initializing player 1 coins
 int player1Coins = startingCoins;
Â
 //Initializing player 2 coins
 int player2Coins = startingCoins;
Â
Â
 for ( int round = 1 ; round <= maxRounds ; round++) {
  Â
   //if the player 1 or player 2 coins are less than 3
   if(player1Coins < 3 || player2Coins < 3) {
     break;
   }
  Â
   //The number of coins player 1 spends
   int player1Spends = getPlayer1Move();
  Â
   //The number of coins player 2 spends
   int player2Spends = getPlayer2Move(round);
  Â
   //Remaining coins of player 1
   player1Coins -= player1Spends;
  Â
   //Remaining coins of player 2
   player2Coins -= player2Spends;
  Â
   //If player 2 spends the same number of coins as player 2 spends
   if ( player1Spends == player2Spends) {
     player2Coins += 1;
     continue;
   }
  Â
   //positive difference between the number of coins spent by the two players
   int difference = Math.abs(player1Spends - player2Spends) ;
  Â
   //if difference is 1
   if( difference == 1) {
     player2Coins += 1;
     continue;
   }
  Â
   //If difference is 2
   if(difference == 2) {
     player1Coins += 2;
     continue;
   }
  Â
  Â
 }
Â
 // At the end of the game
 //If player 1 coins is equal to player two coins
 if(player1Coins == player2Coins) {
   System.out.println("tie game");
 }
 //If player 1 coins are greater than player 2 coins
 else if(player1Coins > player2Coins) {
   System.out.println("player 1 wins");
 }
 //If player 2 coins is grater than player 2 coins
 else if(player1Coins < player2Coins) {
   System.out.println("player 2 wins");
 }
}