Question
Need help I have tried severa; things for each of these questions and still getting them wrong. We are working in java 1.The Game50 dice
Need help I have tried severa; things for each of these questions and still getting them wrong. We are working in java
1.The Game50 dice game is described in the textbook. Here is the partially written Game50 class.
public class Game50{
static final int SIZE = 50; // target score to be exceeded
private int bound; // number of allowable rolls to reach 50
private int rollCount; // number of rolls
private int total; // accumulated dice roll sum
private boolean winner; // game a win or loss?
public Game50(int rollBound){
bound = rollBound; // rollBound value supplied in constructor call in driver class
}
public void playGame(){
initializeGame();
while(!gameOver()){
advancePlay();
showGame();
}
judgeAndReport();
}
}
In the answer box below, enter code that implements the Game50 method initializeGame.
2.The Game50 dice game is described in the textbook. Here is the partially written Game50 class.
public class Game50{
static final int SIZE = 50; // target score to be exceeded
private int bound; // number of allowable rolls to reach 50
private int rollCount; // number of rolls
private int total; // accumulated dice roll sum
private boolean winner; // game a win or loss?
public Game50(int rollBound){
bound = rollBound; // rollBound value supplied in constructor call in driver class
}
public void playGame(){
initializeGame();
while(!gameOver()){
advancePlay();
showGame();
}
judgeAndReport();
}
In the answer box below, enter code for the method gameOver.
3.The Game50 dice game is described in the textbook. Here is the partially written Game50 class.
public class Game50{
static final int SIZE = 50; // target score to be exceeded
private int bound; // number of allowable rolls to reach 50
private int rollCount; // number of rolls
private int total; // accumulated dice roll sum
private boolean winner; // game a win or loss?
public Game50(int rollBound){
bound = rollBound; // rollBound value supplied in constructor call in driver class
}
public void playGame(){
initializeGame();
while(!gameOver()){
advancePlay();
showGame();
}
judgeAndReport();
}
In the answer box below, enter code that implements the code for the Game50 for the private method roll.
4.The Rock-Paper-Scissors gesture game is described in the textbook. Here is the partially implemented RPSGame class.
public class RPSGame {
private int roundsTotal; // number of rounds to play
private int roundsPlayed; // number of rounds that have completed
private String roundWinner; // the winner of the current round
private int oneWins; // number of rounds won by first player
private int twoWins; // number of rounds won by second player
private String oneMove; // first player's move
private String twoMove; // second player's move
private String winner; // which player won?
public RPSGame(int numRounds) {
roundsTotal = numRounds;
}
public void playGame() { // to be implemented in the next question }
private void initializeGame() {
roundsPlayed = 0; oneWins = 0; twoWins = 0; winner = "";
}
private boolean gameOver() {
return (roundsPlayed == roundsTotal);
}
private void advancePlay() {
roundsPlayed++; oneMove = chooseRPS();
twoMove = chooseRPS();
if((oneMove.equals("Rock") && twoMove.equals("Scissors")) || (oneMove.equals("Scissors") && twoMove.equals("Paper")) || (oneMove.equals("Paper") && twoMove.equals("Rock"))) {
oneWins++; roundWinner = "Player One";
}
else if((twoMove.equals("Rock") && oneMove.equals("Scissors")) || (twoMove.equals("Scissors") && oneMove.equals("Paper")) || (twoMove.equals("Paper") && oneMove.equals("Rock"))) {
twoWins++; roundWinner = "Player Two";
}
else {
roundWinner = "Nobody";
}
}
private String chooseRPS() { // implement this method. Use Math.random() and the values .33 and .66 to // make equally likely random choices of "Rock", "Paper", "Scissors". }
private void showGame() {
System.out.println(oneMove + " vs. " + twoMove + ": " + roundWinner + " wins.");
}
private void judgeAndReport() {
if(oneWins > twoWins) winner = "Player One";
else if(oneWins < twoWins) winner = "Player Two"; else winner = "Nobody";
System.out.println();
System.out.println("Player One rounds won: " + oneWins);
System.out.println("Player Two rounds won: " + twoWins);
System.out.println("Winner?: " + winner);
}
}
In the answer box below, enter code that implements the chooseRPS() method. You must enter the entire method, including the header line.
5.The Rock-Paper-Scissors gesture game is described in the textbook. Here is the partially implemented RPSGame class.
public class RPSGame {
private int roundsTotal; // number of rounds to play
private int roundsPlayed; // number of rounds that have completed
private String roundWinner; // the winner of the current round
private int oneWins; // number of rounds won by first player
private int twoWins; // number of rounds won by second player
private String oneMove; // first player's move
private String twoMove; // second player's move
private String winner; // which player won?
public RPSGame(int numRounds) {
roundsTotal = numRounds;
}
public void playGame() { // to be implemented in the next question }
private void initializeGame() {
roundsPlayed = 0; oneWins = 0; twoWins = 0; winner = "";
}
private boolean gameOver() {
return (roundsPlayed == roundsTotal);
}
private void advancePlay() {
roundsPlayed++; oneMove = chooseRPS();
twoMove = chooseRPS();
if((oneMove.equals("Rock") && twoMove.equals("Scissors")) || (oneMove.equals("Scissors") && twoMove.equals("Paper")) || (oneMove.equals("Paper") && twoMove.equals("Rock"))) {
oneWins++; roundWinner = "Player One";
}
else if((twoMove.equals("Rock") && oneMove.equals("Scissors")) || (twoMove.equals("Scissors") && oneMove.equals("Paper")) || (twoMove.equals("Paper") && oneMove.equals("Rock"))) {
twoWins++; roundWinner = "Player Two";
}
else {
roundWinner = "Nobody";
}
}
private String chooseRPS() { // implement this method. Use Math.random() and the values .33 and .66 to // make equally likely random choices of "Rock", "Paper", "Scissors". }
private void showGame() {
System.out.println(oneMove + " vs. " + twoMove + ": " + roundWinner + " wins.");
}
private void judgeAndReport() {
if(oneWins > twoWins) winner = "Player One";
else if(oneWins < twoWins) winner = "Player Two"; else winner = "Nobody";
System.out.println();
System.out.println("Player One rounds won: " + oneWins);
System.out.println("Player Two rounds won: " + twoWins);
System.out.println("Winner?: " + winner);
}
}
In the answer box below, enter code that implements the playGame() method.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started