Question: Java question: /* * WordGame * * beginnings of a Scrabble-like word game * * adds the letter tiles from Scrabble to a bag and
Java question:/* * WordGame * * beginnings of a Scrabble-like word game * * adds the letter tiles from Scrabble to a bag and randomly selects * seven for the user's hand */ public class WordGame { // number of letters in player's hand in Scrabble public static final int LETTERS_PER_TURN = 7; // distribution of Scrabble tiles public static final char [][] ENGLISH_LETTERS = {{'1', 'K', 'J', 'X', 'Q', 'Z'}, {'2', 'B', 'C', 'M', 'P', 'F', 'H', 'V', 'W', 'Y'}, {'3', 'G'}, {'4', 'L', 'S', 'U', 'D'}, {'6', 'N', 'R', 'T'}, {'8', 'O'}, {'9', 'A', 'I'}, {'0', 'E'}}; /* * adds letter tiles to bag according to their distribution */ public static void addLetters(Bag
b, char [] [] let) { // cycle through set of letters for (int i = 0; i let, Bag player) { } public static void main (String [] args) { // add letters to bag Bag letters = new ArrayBag (); addLetters(letters, ENGLISH_LETTERS); // give player seven random letters Bag playerLetters = new LinkedBag (); selectLetters(letters, playerLetters); System.out.println("Your letters are: " + playerLetters); } }
One use for removing random items is a word game like Scrabble in which players select seven tiles for their hand. The file WordGame.java contains a method for adding the Scrabble letter tiles to a bag. Implement a method that randomly removes seven letters from the bag and adds them to a player's hand: public static void selectLetters(Bag
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts

/* * WordGame * * beginnings of a Scrabble-like word game * * adds the letter tiles from Scrabble to a bag and randomly selects * seven for the user's hand */ public class WordGame { // number of letters in player's hand in Scrabble public static final int LETTERS_PER_TURN = 7; // distribution of Scrabble tiles public static final char [][] ENGLISH_LETTERS = {{'1', 'K', 'J', 'X', 'Q', 'Z'}, {'2', 'B', 'C', 'M', 'P', 'F', 'H', 'V', 'W', 'Y'}, {'3', 'G'}, {'4', 'L', 'S', 'U', 'D'}, {'6', 'N', 'R', 'T'}, {'8', 'O'}, {'9', 'A', 'I'}, {'0', 'E'}}; /* * adds letter tiles to bag according to their distribution */ public static void addLetters(Bag