Question: QUESTION:1 PLEASE solve this using Java code: Elimination is a one-player game. The board consists of a set of 12 tiles, numbered 1 through 12.




QUESTION:1 PLEASE solve this using Java code: Elimination is a one-player game. The board consists of a set of 12 tiles, numbered 1 through 12. The player rolls a pair of dice and marks tiles as removed based on the numbers shown on the dice. For each roll, the player can either "mark removed" the two tiles corresponding to the numbers shown on each die or a single tile corresponding to the sum of the numbers on each die. If the player rolls doubles (the same number on both die), the player can "mark removed" only the tile corresponding to the sum of the numbers on each die. Play continues until the player cannot make a legal move after rolling or all the tiles have been "mark removed". The sum of the remaining tiles is the player's score. The goal is to have a low score. In addition to playing the game, your application should keep track of the best (lowest) score of all plays during a single run. Here is a sample run of the application: Lowest Score = 78 1 2 3 4 5 6 7 8 9 10 11 12 Dice roll: 43 What is your move (V=values, S=sum, Q=quit)? V 1 2 3 4 5 6 7 8 9 10 11 12 ..XX....... Dice roll: 25 What is your move (V=values, S=sum, Q=quit)? V 1 2 3 4 5 6 7 8 9 10 11 12 .XXXX....... Dice roll: 65 What is your move (V=values, S=sum, Q=quit)? V Try again. What is your move (V=values, S=sum, Q=quit)? S 1 2 3 4 5 6 7 8 9 10 11 12 .XXXX...... Dice roll: 45 What is your move (V=values, S=sum, Q=quit)? S 1 2 3 4 5 6 7 8 9 10 11 12 .XXXX...X.X. Dice roll: 45 What is your move (V=values, S=sum, Q=quit)? S Try again. What is your move (V=values, S=sum, Q=quit)? V Try again. What is your move (V=values, S=sum, Q=quit)? Q 1 2 3 4 5 6 7 8 9 10 11 12 .XXXX...X.X. Score = 44 NEW LOW SCORE! Lowest Score = 44 Do you want to play again (Y=yes, N=no)? You need to complete the partially completed "Elimination" (void main) class which plays the game. Here's what I have SO FAR below: import java.util.Scanner; public class Elimination { public static void main(String[args) { Scanner in = new Scanner(System.in); Board B = new Board(); int die 1, die2; boolean legalMove; String choice = ""; 11 while (!choice.equalsignoreCase("Q")) { System.out.println(" " + B); die 1 = (int)(i + Math.random()*6); die2 = (int)(1 + Math.random()*6); legalMove = false; System.out.println("Dice roll: " + die 1 + + die2); while (!legalMove) { System.out.print("What is your move (V=values, S=sum, Q=quit)? "); choice = in.next(); if (choice.equalsignoreCase("Q")) { legalMove = true; } else if (choice.equalslgnoreCase("S") && B.remove Tile(die 1+die2)) { legalMove = true; } else if (choice.equalslgnoreCase("V") && B.remove Tiles(die 1, die2) ) { legalMove = true; } else { System.out.println("Try again."); } System.out.println(" "+B); System.out.println("Score = " + B.score()); } } You also need to complete the partially completed "Board" (non-void main) class that does no input or output. Here's what I have SO FAR below: public class Board char board[]; public Board() { board = new char[12]; for(int i = 0; i = 0 && newIndex = 0 && newlndex1 = 0 && newIndex2
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
