Jump to content
Sal's RuneScape Forum

hoshanaeckhart

New Member
  • Content Count

    2
  • Joined

  • Last visited

Community Reputation

0 Relatively Unknown

About hoshanaeckhart

  • Rank
    Newbie Forumer

About My Character

  • RuneScape Status
    Freeplayer
  • RuneScape Version
    Classic

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. hoshanaeckhart

    Jumble Solver

    Hi.I need help starting this assignment. The teacher/class is way over my head and I HAVE to do well on this assignment to pass...So if anyone could assist me in doing and understanding this assignment, it would be greatly appreciated.Thank you!____________________________________________________________________________We will write a program to solve word jumbles. You have probably seen them in the newspaper every day. Quick - what word is formed from the letters 'mezia'? 'cidde'? 'hucnah'? 'bouste'? Your program will solve these by brute force. It will have a list of English words (from Program 8, Spell Checker), and it will generate all permutations of the letters in the jumble. When it finds a permutation that is in the word list, its done.RequirementsFirst, use your WordListIndexed to store the English language dictionary from the Spell Checker program. Our jumbles won't contain any punctuation marks or abbreviations. Don't store them in your WordListIndexed.The primary class in this assignment, StringPermutationIterator, generates all the permutations of the letters in a given string. This class must have an iterator interface: next( ) and hasNext( ) (no remove( ) member function). There are two major challenges for this class. First, generate the permutations recursively. For example, to generate the permutations of a four letter string, put one of the four letters as the first letter and combine it will all permutations of the remaining 3 letters. Repeat until each letter has been used at the front (see example). For simplicity, you may assume that all the letters in the input string are unique (no duplications). If this assumption does not hold then we simply generate some duplicates that cause your program to run a little slower. We still get the correct result. Second, you must generate the permutations incrementally. It is not allowed to generate all permutations, store them in a list, and have the iterator walk down the list. Nor is it allowed to utilize the fact that there will be exactly n! permutations. You must create a true dynamic iterator that generates one at a time the elements of the set of permutations. See the general plan for dynamic iterators*.Primary classes: StringPermutationIterator.Application: Write a short main method that unscrambles the 4 jumbles from the first paragraph of this assignment plus 'ueassrkpc'.____________________________________________________________________________See example:SPI("cats")'c' + an of SPI("ats"). When SPI("ats") rolls over (false == hasNext()), createan new nested SPI object'a' + an object SPI("cts"). When SPI("cts") rolls over, create a new SPI object't' + an object SPI("cas") create SPI("cat")'s' + an object SPI("cat") When SPI("cat") rolls over, we are done.SPI("cats").hasNext() == false*General plan for dynamic iterators:public class DynamicIterator<String>implements Iterator<String> {String buffer;boolean hasNext() { return buffer != null; }String next() {String result = buffer;buffer = createNextElement();return result;}}
  2. Hey everyone! So I am very new to the Java language, and I am trying to figure out how to design and implement a word unscrambler game that reads a word from a text file, scrambles it, and allows the user to switch the character indexes as they please...Here is my code. 01 import java.util.* 02 import java.io.* 03 04 public class Unscrambler 05 { 06 //----------------------------------------------------------------------------------------- 07 // This program reads a random word from a file created separately called words.txt that 08 // has been provided. The program then scrambles the word by swapping random letters a 09 // random number of times. The scrambled word is displayed with character indexes on top. 10 // The user selects 1 to swap a pair of letters, 2 to print the word unscrambled and quit, 11 // and 3 to simply quit. When the word is scrambled correctly, the computer congratulates 12 // the user, repeats the unscrambled word, and the number of steps it took to solve. An 13 // error message appears if invalid indexes are input by the user. 14 //----------------------------------------------------------------------------------------- 15 16 public static void main (String[] args) throws IOException 17 { 18 //Setting Up Variables and Scanners wordsia to read from User and words.txt 19 String words; 20 Scanner fileScan, wordsScan, optionScan; 21 int option; 22 boolean done = false; 23 Random generator = new Random(); 24 25 fileScan = new Scanner (new File("words.txt")); 26 words = filescan.nextLine(generator.nextInt(22); 27 optionScan = new Scanner (System.in); 28 29 while (!done) 30 { 31 //Menu 32 System.out.prinln ("Welcome Computational Unscrambling!"); 33 //read from User 34 option = optionScan.nextInt(3) + 1; 35 36 if (option == 1) 37 { 38 //Allow user to switch letters between index; 39 //If User unscrambles word, done == true; 40 } 41 else 42 { 43 if (option == 2) 44 { 45 //Print the unscrambled word and quit 46 } 47 } 48 else 49 { 50 if (option == 3) 51 { 52 //Just quit the program 53 } 54 } 55 } 56 } 57 } Basically, I think I have the structure set up....but I don't know how to scramble the actual words...I know I should use the random generator to switch the characters but I don't really have any clues as to what else to do. I included the comments to enhance readability. If anyone could offer some suggestions that would be appreciated.Thanks, everyone!
×

Important Information

By using this site, you agree to our Guidelines and Privacy Policy.