Task Description Your task is to create a game where the users can play with words and numbers. The game hasthree consecutive levels (Level 1, Level 2, and Level 3). Users can proceed to the next...

Task Description Your task is to create a game where the users can play with words and numbers. The game hasthree consecutive levels (Level 1, Level 2, and Level 3). Users can proceed to the next level after successfully finishing the current level. At each level, the users will be asked to perform a task. Users will be notified about the outcome (success or failure) of the task. Upon a failure, the user can try the task one more time. Once the task is (successfully) completed, the user will be proceeded to the next level and notified. Two consecutive failures for a task (in a particular level) will end the game. A user will win if he/she finishes all four levels successfully. Game class: You need to define a dedicated class (Game.java) to store the commonly used variables and methods (e.g., showing notification/instruction) that you will use in other parts of the program. Use of inheritance and comments: You must apply inheritance in your program. You need to also add comments for each of your classes, methods, and key variables/fields. Input/output: You can use standard Java I/O streams such as System.in and System.out to take input from the users and show output to the users. The input and output of your program should be continuous until the game finishes with a failure or win. Level 1 - Anagram What is an anagram: An anagram consists of creating a new word/phrase by rearranging the letters of a given word/phrase. Some examples of anagrams are given below. elblow: below, night: thing, meteor: remote It is possible that a single word/phrase will have multiple anagram words/phrases. Program features: At the beginning of the level, your program will notify users about this level and the task the users need to complete. Following that, your program will display the letters of a randomly selected word for each play and attempt. The users will have to input all meaningful (not just combinations of letters) words resulting from rearranging the letters (anagrams). For example, “laets” is not a valid anagram of “tales”. Therefore, the following cases would be considered as an invalid word input if the user enters: - an invalid anagram (random combination of the word letters) - a valid anagram that does not exist in the dictionary - any valid or invalid word that does not consist of the given letters The users complete this task if at least two words entered by the users are valid. Your program will display which of the inputted words are valid and not. Upon completion of the task, your program will notify the users by displaying “Congratulations! You completed level 1 successfully”. If zero or only one inputted word is valid, this would be a failed attempt, and the program must display “Fail! at least two input words must be valid”. Two consecutive failures in this level will end the game. Users can input a sequence of words separated by spaces. Anagram dictionary: You need to use the below anagram dictionary of 20 words. Using an appropriate collection, you must implement this dictionary in the Game class. Anagram dictionary Source word Anagrams late tale, teal. pate peat, tape. pare pear, reap. parse asper, pares, pears, prase. rate tare, tear. tales stale, slate, tesla, steal, least. east eats, sate, seat, seta, teas. alerts alters, artels, estral, laster, ratels, salter, slater, staler. post pots, spot, stop, tops. alerting altering, integral, relating, triangle. steak skate, stake, takes. live evil, veil, vile. meat mate, team, tame. insert estrin, inerts, inters, niters, nitres, sinter, triens, trines. laser earls, reals, rales, lares. lapse peals, pleas, pales, sepal. angle angel, glean, genal. super purse, sprue. scrape capers, crapes, spacer, pacers. retains stainer, starnie, resiant, nastier, retinas. This dictionary can be used in many parts of your program for different purposes, e.g., choosing the desired alphabets for the users and comparing if an anagram inputted by the user is valid. Randomly selecting a word: The Random class (java.util.Random) can be used to generate a random number within a range (0 - 20). This randomly generated index can be used to select the word from the dictionary. Select a random word: //Step 1. Create a new instance of the Random class; //Step 2. Generate an integer between 0 and 19 using nextInt() method //Step 3. Use the integer as index and select the word from the array //Step 4. Return the selected word as a string End Retrieving anagram list: Once you have identified the word, you can easily retrieve the corresponding anagrams using the get() method of the dictionary instance. Get anagram lists (input is the word): //Step 1. Use the get() method to retrieve anagram lists from the dictionary //Step 2. Returns the anagram lists as a string array End Displaying letters of the selected wordou can use the toCharArray() method to convert a string into a list of characters.
Apr 14, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here