Question: import java.util.ArrayList; import java.util.Scanner; //Algorithm //Input: how many dice to use, 6 sided dice, how many players //Output: biggest number that can be created with

import java.util.ArrayList; import java.util.Scanner;
//Algorithm //Input: how many dice to use, 6 sided dice, how many players //Output: biggest number that can be created with the digits on the dice roll //Step 0: //Step 1: ask user how many dice to use //Step 2: Store it in numOfDice //Step 3: Make an array of Dice objects that is numOfDice in length //Step 4: Roll the Dice -> all of the Dice now have a value //Step 5: Make max = DiceArray[0].value //Step 5: FOR each item in DiceArray // Step 5.1: IF DiceArray[i].value > max THEN // Step 5.1.1: max = DiceArray[i].value //Step 6: Store the max value in biggestNum in the ones place - moving all other digits to // left one place //Step 7: Take that Dice object with the max value out of our list //Step 8: Go back to Step 5 until our list is empty //Step 9: Output the number
public class BeatThatGame {
public static void main(String[] args) { int biggestNum = 0; //Step 1: ask user how many dice to use Scanner input = new Scanner(System.in); System.out.println("How many dice will you be playing with?"); //Step 2: Store it in numOfDice int numOfDice = input.nextInt(); //Step 3: Make an array of Dice objects that is numOfDice in length ArrayList
}
public class Dice { //attributes private int value; private int numOfSides; public Dice(int numOfSides) { this.numOfSides = numOfSides; value = 1; } public Dice() { this.numOfSides = 6; value = 1; }
public int getValue() { return value; }
public void setValue(int value) { this.value = value; }
public int getNumOfSides() { return numOfSides; }
public void setNumOfSides(int numOfSides) { this.numOfSides = numOfSides; }
@Override public String toString() { return "Dice [value=" + value + ", numOfSides=" + numOfSides + "]"; } public int roll() { return value = (int)(Math.random() * numOfSides) + 1; }
}
For this Homework assignment you will add functionality to the code we wrote in class: BeatThat Game.java E Dice,java A functionality would be adding a Player object to keep track of the Players and their scores in our game. Making the game repeat and play as often as the user wishes. You could instead a feature to add betting, and allow the user to win or lose coins. Or some other kind of functionality. Note that you should add at least 20 lines of code to be counted as functionality. BEAT THAT! Beat That is a fun game that can be played by children aged 5 upwards. The number of dice used within the game can vary depending on the age of the children. For example, younger children may be fine with two dice, whereas older children may prefer more of a challenge, so potentially up to 7 dice could be used within the game. All that is needed to play Beat That is dice and a paper and pencil for scoring. Children are passed the dice and have to come up with the largest number possible combining the dice thrown. For example, if a child was using two dice and came up with a 6 and a 7, the highest number that could be achieved is 76. Similarly, if a child was using three dice and the numbers rolled were 4,6 and 8, then the highest number possible would be 864. Once players have come up with the highest number they think is possible, the dice are then passed to the next player with the invitation of 'Beat That! Children play in rounds, with a winner being declared at the end of each round If attempting to score the highest number becomes a little repetitive, then why not consider changing the rules round, like attempting to reach the smallest number possible. After writing the algorithm you are them to implement the algorithm in code. You must use the Dice and Player objects when implementing this algorithm. You can use the Dice and Player classes that were written in class, or use your own Dice and Player classes. You can ask the user how many players there will be playing the game. The last player should be the computer. You should keep points for each player and ask if they would like to play again after the round is over. Output the total points after each round You are to turn in your algorithm and code for this assignment
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
