Specification
For this assignment, you will write a program for a person to play a word game called Learndle. Thissection specifies the required functionality of the program, Only a text interface is required forthis program; however, more marks will be gained for a game that is easy to follow with clearinformation/error messages to the player.
The aim of Learndle is for a player to correctly guess a hidden word in a set number of attempts.After each incorrect guess the player is shown the letters in the word they have guessed that are inthe correct position in the hidden word, The game continues until the player has correctly guessedthe word or they have run out of attempts.
The player may play a series of games. At the end of each game the player is awarded a scoreaccording to the number of attempts they have taken to guess the word, At the end of the series ofgames the player is shown their maximum game score.
Rules of the Learndle game
1. The Learndle game begins with a message inviting the player to enter their name, The name cancontain only contain lower case alphabetic characters and must be no more than eight characters irength, If the plaver enters an invalid name then a warning message is displayed and the player isinvited to enter another name. This will not count as an attempt.
2. The length of the hidden word that the player has to guess is displayed on the screen. The wordength is randomly chosen to be either four, five or six characters. Each word length is equallypossible.
3. The hidden word is chosen by the computer. The word is not shown to the player. To generatethe hidden word, you'll need to use the provided Learndlekeywords,class file, This class containsa static method called generateRandomkeyword(length) , which generates a hidden word based onthe specified length. The length should be between 4 and 6, inclusive -earndlekevwords,generateRandomkevword(length)
4, The maximum number of attempts allowed to guess a word is one less than the length of theword. For example, for a five-character word, four attempts are allowed.
5. The player is then invited to enter a word to guess the hidden word. The word entered must bethe same length as the hidden word. lf the word length does not match that of the hidden wordthen the guess is invalid, ln this case the player is given a warning message and no information isgiven about the whether any characters are correct, This will not count as an attempt
For each valid guess the following outcomes are possible:
The player has correctly guessed the word. In this case the game ends and the player is showntheir game score (see rule 6).
The player has incorrectly guessed the word and has used all their attempts. In this case thegame ends and the player is shown their game score (see rule 6).The player has incorrectly guessed the word and has not used all their attempts, In this casethe player is shown the correctly guessed letters for the hidden word. For each characterposition in the guessed word: lf the guessed character matches the character at the same position in the hidden word
that character is displayed.o lf the guessed character does not match, an underscore character () is displayedFor example, if the hidden word is "number" and the player enters "queues" then the playerwould be shown "' u_ _e ". This indicates that the second character in the hidden word is "u"and the fourth character is "e," while the other characters are still unknown, This feedbackhelps the player narrow down the possible correct letters in the hidden word and make moreinformed guesses in subsequent attempts. The game continues until the player either guessesthe word correctly, runs out of attempts, or chooses to end the game.
6, At the end of the game the game score is displayed to the player, The game score is calculated asfollows:
game score = (word length - number of attempts) * correct guesswhere the correct guess is 0 (zero) if the correct word was not guessed and 10 if the correct word wasguessed.
7. At the end of the game the player is then invited to play another game.
8. lf the player decides to not continue with another game then their highest game score isdisplayed.
Program design
Your program should consist of at least three classes: Player, Learndle, and WordLength Thefollowing sections give details of these classes.
Player class
The Player class will specify the attributes and behaviours of a player. An object of the Player classwill have at least the following fields:
Name - the name of the player
Score - the highest game score
The data type of each field must be chosen carefully and you must be able to justify the choice ofthe data type of the fields. You may want to include comments in the class to state any assumptionsmade. The class must also have a default constructor and a non-default constructor that accepts avalue for the name of the player.
The Player class should also have appropriate accessor and mutator methods for its fields.Validation of values for fields should also be implemented, You should not allow an object of classPlayer to be set to an invalid state. There should be no input from the terminal or output to thescreen via methods from the Player class. A Plaver object should also be able to return its state inthe form of a String
Learndle class
The Learndle class will manage the playing of a the game. lt will have the following fields (at least):
Player - an object of type Player
Word length - the length of the hidden word
Hidden word - the word the player will attempt to guess
The Learndle class will have methods to manage the plaving of the game, These should include themain() method to start the program and methods for the following behaviours (at least):
Display a welcome message on the screen.
Request the player to enter their name.
Get the length of the hidden word
Get the hidden word
Display the result of guess.
Display the score at the end the game.
Display the highest game score
WordLength class
An object of the WordLength class will generate a random word length from a minimum to amaximum word length, inclusive.
Assessment
Assessment for this assignment will be done via an interview with your tutor. The marks will beallocated as follows:
10% - Progress of code development, as shown via Ed workspace environment. Your tutor will
assess your work during your applied session in weeks 5 and 6.5% in week 5 for Class Diagram (this can be hand-drawn). Note that the class diagramoshould show the individual classes and the interactions between the classes but does
not need to include the details within the classes.o5% in week 6 for Player and WordLength classes10% - Class diagram (including class interactions and internal details), Java code quality andobject-oriented design quality. This will be assessed on code quality (e.g. compliance withcoding standards) appropriate design and implementation of classes, fields, constructors,methods, and validation of the object's state.20% - Program functionality in accordance to the requirements.60% - Oral assessment.
Assessment for this assignment will be done via an interview with your tutor. The marks will beallocated as follows: