Alright, I'm not looking for an EXACT solution (Unless you seriously want to give the time to help me out that much) I'm just looking for where I should start and maybe a really nice detailed algorithm.
I've got an assignment to create a Word Jumble game played between two players. I've got some fairly specific guidelines I need to follow which I will post:
For this assignment you are to create a simple word guessing game for two players. For each round in the game the following sequence is followed:
first player enters a word to be guessed
the program rearranges the letters in the word and displays to the second player
the second player has 5 attempts to guess the word correctly
second player enters a word to be guessed
the program rearranges the letters in the word and displays to the first player
the first player has 5 attempts to guess the word correctly
The scoring for the game is as follows:
100 points if guessed on first try
80 points if guessed on second try
60 points if guessed on third try
40 points if guessed on fourth try
20 points if guessed on fifth try
The players have the option to play as many rounds as they would like. The game is over when players select “quit program” from the menu.
The program will automatically play the first round. After that a menu will appear to allow the players the option of displaying their score, playing another round, ending the game or quitting the program immediately. The menu will appear as follows:
Please select from one of the following options:
p - play another round
s - display current score
e - end game and display final score
q - quit program
For this problem you are required to create specific classes and methods. The following classes and methods are required.
This class maintains information about a player. It has two private attributes, name and score. The following methods are required for this class:
Player( name : String ) Constructor which creates a new instance with name specified.
increaseScore( amount : int ) Method which adds the specified amount to the player’s score.
resetScore( ) Method resets player’s score to zero
getName() Accessor method which returns player’s name
displayScoreDetails() Method which displays the player’s name and score to console output in the form “name: score”.
findWinner( player1 : Player, player2 : Player ) This static method accepts two Player instances and determines which of the players has the higher score. The method returns the Player instance of the player with the highest score. If the players are tied this method returns null as there is no winner.
This class maintains information about a word. It has one private attribute, word. The following methods are required:
Word( word : String ) Constructor accepting word to use.
Word() Constructor which uses the default word of “popcorn”. Use constructor chaining.
getWord() This method returns the word.
getJumbledWord() This method returns the word with the letters mixed up. This method must mix up the letters by taking the original word and performing ten letter swaps. This method should have a loop that loops ten times. Each time through the loop randomly pick two letters and swap their positions in the word.
doesWordMatch( otherWord : String ) This method compares the provided word to its word. If the word is an exact match it will return true otherwise it returns false. Note: case is irrelevant so make sure the case is ignored.
This is the class that plays the game. It makes use of the Player and Word classes. It has three private attributes, player1, player2 and input. The input attribute represents the Scanner instance and is used for getting input from the user. The following methods are required for this class:
main( args : String ) Main entry point for the Java application. This method should instantiate the Jumble class and call the playGame method.
Jumble() Constructor. Displays welcome message and creates two new player instances. Use the getPlayerName method to get the two player names.
getPlayerName() This method gets the user to enter a player name. Make sure the player name is at least one character long.
getPlayerGuess( word : Word, player : Player ) This method is responsible for getting a player’s guess for a word. This method should do the following:
- clear the screen by displaying 25 blank lines
- use a loop to allow the player up to five guesses
- ask the player for their guess
- if the guess is correct, add appropriate amount to player’s score. Amount to add is based on which guess it is. First guess is 100 points, second is 80, third is 60, fourth is 40 and fifth is 20. If the player does not guess within five guesses, the player scores nothing.
playGame() This method handles the main loop for playing the game. The loop should loop while the user wants to keep running the program. The first time through the loop, the first round should automatically be played. Within this loop do the appropriate action based on the choice selected by the user. The choices are:
- play a round. Each player gets to provide one word that the other player then guesses. Ask each player to enter a word and use the getPlayerGuess method for having the other player guess the word.
- display the current score for each player. Use the displayScoreDetails method in the Player class.
- end the game and display the final score for each player, including indicating who won the game. Call the displayWinner method in the Jumble class.
- quit the program. Terminate the program. No scores are displayed, and no indication is given of who won the game.
Use the getMenuChoice method to display the menu and get the user choice.
displayWinner() Use the findWinner method in the Player class to determine who is the winner. Use the displayScoreDetails to display the final score for each player. Reset the scores for each player.
getMenuChoice() This method should display the menu and get the user choice. Make sure the input is validated.