1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
lianna [129]
3 years ago
14

Assume that getPlayer2Move works as specified, regardless of what you wrote in part (a) . You must use getPlayer1Move and getPla

yer2Move appropriately to receive full credit. Complete method playGame below. /** Plays a simulated game between two players, as described in part (b). */ public void playGame()
Computers and Technology
1 answer:
kakasveta [241]3 years ago
3 0

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");

  }

}

You might be interested in
Omega Software Inc. is currently running a training program for employees to upgrade their software skills so that they are able
MArishka [77]

Answer:

Omega Software is attempting to make a change in the area of people.

Explanation:

Types of Organizational Change:

Most organizations have to go through a change to keep up with the changing market dynamics, trends and technologies. There are four major types of organizational change:

  1. Structural
  2. Strategic
  3. People
  4. Process

People change:

One of the organizational change is people change where organizations strive towards the improvement of their employee's skills set and productivity. This is usually achieved by launching various specialized and general training programs for employees to enhance their knowledge and widen their skills set so that they can work more efficiently for the organization.

Therefore, it can be concluded that Omega Software is attempting to make a change in the area of People.

3 0
3 years ago
List any four e-commerce website​
Ipatiy [6.2K]

Answer:

Amazon. Founded in the US in 1994, Amazon started as an online bookstore that later diversified to products including media, electronics, apparel, furniture, food, toys, and jewelry.

eBay. ...

Walmart. ...

Etsy. ...

Home Depot. ...

Target. ...

Best Buy. ...

Wayfair.

5 0
3 years ago
Read 2 more answers
There is no need to schedule video calls ahead of time; they can be used the same way as
UNO [17]

Answer:

The answer to this question is "True".

Explanation:

The term video calling is part of communication. In this type of communication will be used in every place like house, office for video conferencing, etc. It was developed in 1968 by AT&T's Bell Labs. It works on internet.This type of calling we can face to face communicate means, we watch the person. In the video calling, there is no need for a schedule it is used as a phone call.  

6 0
3 years ago
Why would students most likely need to collect data? Check all that apply
n200080 [17]
Well I would think all of them in some way. For the first one, students need to collect data (whether it’s mathematical, scientific, etc.) to answer a question. For the second one, they may need to know how much money is in there bank account or they may need to calculate a sale to order the item. For the third one, they may need statistical data to support a position. For the last one, a student could use technological data to be able to solve their problem sorting documents.
5 0
3 years ago
Read 2 more answers
When comparison shopping, all of these hint at a good deal EXCEPT_____________________.
pav-90 [236]

Answer:

lower-priced models offer more features

Explanation:

4 0
3 years ago
Other questions:
  • Rewrite this method so that it avoids the use of a return statement:
    15·1 answer
  • Properly defined the primary part of a CPU​
    5·1 answer
  • In a database, __________ is used to uniquely identify each record for retrieval or manipulation. answer an attribute or a field
    7·1 answer
  • When you align or size a group of selected controls, the changes are made relative to the
    14·1 answer
  • What was a result of george washington's belief in the sovereignty of the people instead of monarchy?
    9·1 answer
  • shapes polymorphism Create a set of classes derived from an abstract class Shape, which provides a common interface, for managin
    7·1 answer
  • 5. Which of the following views is used to run a PowerPoint presentation?
    11·2 answers
  • Pls help will give brainlest​
    15·2 answers
  • Tell me the most scariest website you know and i'll give you brainlest
    5·1 answer
  • Who's hype for Halo Infinite?
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!