Create a class WordPath. Its constructor should take a UserInterface and store it in a class variable. public class WordPath { // WordPath class UserInterface ui; // class variable WordPath...

Create a class WordPath. Its constructor should take a UserInterface and store it in a class variable. public class WordPath { // WordPath class UserInterface ui; // class variable WordPath (UserInterface ui) { // constructor that takes a UserInterface this.ui = ui; // and stores it in a class variable } In its main method, create a new WordPath with a new GUI and store the WordPath in game. Ask the user for a starting word and a target word. Ask if the human or the computer should play: String[] commands = { "Human plays.", "Computer plays." }; Call game.play or game.solve with the starting word and the target word. (solve will empty for now.) In play, do the following forever (until the return occurs). Tell the user the current word (the start) and the target word. Ask for the next word. Set the start word variable to that next word. If it equals the target, tell the user ``You win!'' and return. Otherwise keep looping. Test. HOMEWORK 6. Create a static boolean method oneLetterDifferent which takes two String as input and returns true if they have the same length and differ in exactly one character. Modify play so that it calls oneLetterDifferent. It should warn the user and NOT change the current (start) word variable if the word that the user suggests is not one letter away from the current start word. Test. 7. In LinkedQueue.java, implement offer, peek, and poll. Don't forget about incrementing and decrementing size. Test using MaintainQueue. The list won't be printed yet. 8. Implement Iter. This time the entry variable in Iter is of type Entry. When you are sure you have tested it thoroughly using MaintainQueue, run TestLinkedQueue. 9. In Wordpath main, just after creating the new WordPath in main, ask the user for the name of a word file and call game.loadWords(filename). Add a private static Entry class to WordPath with a String word and an Entry previous but NOT a next. Add a List wordEntries to WordPath initialized to an ArrayList. For each word in the word file, loadWords should read in the word, create a Entry from it, and add this Entry to wordEntries. Write a find method that takes a String word and finds that word in wordEntries. It should return the entry for that word or null if not there. Modify play so it also refuses a word not in words. Test using the words file called words in the prog06 directory: copy it to the csc220 Eclipse project folder XXXXXXXXXXNow to implement WordPath.solve. Inside solve, create a Queue of Entry. Find the entry belonging to the start word and put it into the queue. Also save it in a variable since you will need to refer to it again later. While the queue is not empty, remove a entry, and call it theEntry. Go through the list wordEntries and look for entries which aren't the start entry, don't have previous set yet, and are one letter different from theEntry. For each one you find, call it nextEntry. Set nextEntry previous to theEntry and add nextEntry to the queue. If the word in nextEntry is the target, then report success. To get the solution in reverse order, follow previous back to the start entry. Display the solution in forward order.

May 18, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here