Question
help me how to start The game of Snowman In this assignment, you implement a player for a familiar childrens game in which your program
help me how to start
The game of Snowman
In this assignment, you implement a player for a familiar childrens game in which your program tries to guess a secret word one letter at a time. For example, if the secret word is snowman, then the player begins with the letters hidden: *******. Each guess that does not appear in the word is a miss and scores one point. Each guessed letter which does appear in the word replaces the corresponding asterisks with the correct letter. For example, a guesss of n, results in *n****n. The fewer misses your program does overall, the better. The guessing ends when all of the letters have been guessed, to reveal the hidden word, in this case snowman.
To be able to write and execute this assignment, you need to download the following files and save them to the same directory in which you write your project:
words.txt, the 2.5 megabyte raw text file containing the list of possible words in the English language, one word per line. From this dictionary, only the proper nouns that contain only lowercase letters are used in the game.
SnowmanRunner.java, the automated tester for your Snowman code.
[page1image18360]
Class specification and methods to write
You must write and submit on D2L exactly one Java sourcecode file named SnowmanPlayer.java. This class must have all four of the following methods, with names and signatures exactly as specified below. (Otherwise, our SnowmanRunner tester class can't be compiled and executed with your class.) In addition, you may write in your class whatever private utility methods and data fields you wish. Furthermore, you are allowed to use and call any existing classes and methods in the Java standard library, such as ArrayList or various String processing methods.
Your methods must operate in silence and not print anything on the console, so as not to mess up the output of the tester class. Of course you can do some debugging prints during the development phase, but before submitting your SnowmanPlayer, you must absolutely comment out all output statements in it.
public static void startGame(String[] words, int minLength, int maxLength, String allowedChars)
This method is guaranteed to be called exactly once by SnowmanRunner at the beginning of the program execution, and after that, never again. Inside this method, you can do whatever initialization computations you wish to perform to optimize your success in the game, such as counting the individual letter frequencies in words. The parameters are as follows:
words is an array of Strings that contains all possible words of English that the secret words are randomly chosen from.
minLength and maxLength are the minimum and maximum lengths of the secret words, respectively. Your code can safely assume that the secret word length is between these two, inclusive.
allowedChars is a String that contains all possible characters that can occur in the secret words. (This would be the 26 lowercase letters of the English alphabet.)
public static void startNewWord(int length)
The method startNewWord(int) is called by SnowmanRunner at the start of each new round (which will have a new secret word). Inside this method, you can perform whatever initialization you need for guessing each individual secret word. The parameter length tells you the length of the secret word (so that you can ignore all the potential secret words that have a different length).
public static char guessLetter(String pattern, String previousGuesses)
The method guessLetter(String, String) is called by SnowmanRunner to ask your code what letter it would like to guess next for the current secret word. Your method answers by returning a char. The parameters of guessLetter() are as follows:
pattern is a String that contains the current secret word so that each unknown letter is displayed as the character SnowmanRunner.BLANK (currently the asterisk character), and each known letter is displayed as that letter. For example, if the secret word is seven characters long, and you have previously made the successful guesses 'n' and 's', the pattern might be "sn****n".
previousGuesses is a String that contains the characters that you have already guessed for this particular secret word, including both hits and misses. (Of course, it would be rather silly for your method to return as your guess some character from previousGuesses, or some character that is not in allowedChars.)
import java.util.*; import java.io.*;
public class SnowmanRunner {
/* You are allowed to modify the following three class variables. */ private static int SEED = 654321; private static final int ROUNDS = 20; private static final boolean VERBOSE = true; /* DO NOT MODIFY ANYTHING BELOW THIS LINE !!!! */ public static final int MINLENGTH = 5; public static final int MAXLENGTH = 15; private static final String allowed = "abcdefghijklmnopqrstuvwxyz"; public static final char BLANK = '*'; private static List
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