Results 1 to 10 of 10
  1. #1
    Shadow22202 is offline Member
    Join Date
    Apr 2008
    Posts
    5
    Rep Power
    0

    Default Scrambling Words

    All I need to know how to do is scramble a word such as "Superman" so that each time I run the program is jumbles the word (i.e. punamres or seurmpan). Each run needs to be a different "scramble" Thank you

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  3. #3
    Shadow22202 is offline Member
    Join Date
    Apr 2008
    Posts
    5
    Rep Power
    0

    Default

    I need to know how to do that, however I dont think that will work, I need to have a word bank and from that word bank use an array to grab a word then shuffle it.

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    What you mean a word bank? You mean you have a bunch of scramble words with you? If so it is too easy.

  5. #5
    Zosden's Avatar
    Zosden is offline Senior Member
    Join Date
    Apr 2008
    Posts
    384
    Rep Power
    7

    Default

    I would just put the string into a char vector and then just pull out random indexes from it then put that into an array in order. That would work the best. if you want to do your way, which by the way is stupid. then just have your arrays hard coded into the code then just use a switch statement to figure out which one to use.
    My IP address is 127.0.0.1

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Yep, that what I want to figure out pal. If he already stored words, in an array, list, etc.., randomly generate the index and refer that indexed word.

    It's much simple, rather generating the random characters.

  7. #7
    Zosden's Avatar
    Zosden is offline Senior Member
    Join Date
    Apr 2008
    Posts
    384
    Rep Power
    7

    Default

    Oh I'm sorry I misinterpreted what he meant. I thought he meant he wanted to have a user input words then pick from an array that had the word already scrambled. I apologies for misreading.
    My IP address is 127.0.0.1

  8. #8
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  9. #9
    aleshivan's Avatar
    aleshivan is offline Member
    Join Date
    Apr 2008
    Posts
    1
    Rep Power
    0

    Default Scrambling String

    Quote Originally Posted by Shadow22202 View Post
    All I need to know how to do is scramble a word such as "Superman" so that each time I run the program is jumbles the word (i.e. punamres or seurmpan). Each run needs to be a different "scramble" Thank you
    para revolver una palabra yo haria lo siguiente:
    Java Code:
        public int randPos(int max){
            return (int)(max * Math.random());
        }
    
        public String scrambleString(String inStr){
            char[] chars = inStr.toCharArray();
            for (int i = chars.length - 1; i > 0; i--) {
                int guest = randPos(i);
                char current = chars[guest];
                chars[guest] = chars[i];
                chars[i] = current;
            }
            return new String(chars);
        }
    Buena suerte
    Last edited by aleshivan; 04-29-2008 at 08:49 PM. Reason: Corrección de estilo

  10. #10
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Dear aleshivan,

    Welcome to our community. :)

    I can't understand your language here. I think not only for me, most of us here in this community. So please make all your replays in English, which is everyone can understand.

    I hope you get what I say.

Similar Threads

  1. Replies: 4
    Last Post: 07-07-2008, 01:32 PM
  2. help w words
    By Gilgamesh in forum New To Java
    Replies: 5
    Last Post: 11-21-2007, 06:15 PM
  3. program help: Extracting words from a string
    By toad in forum New To Java
    Replies: 1
    Last Post: 11-04-2007, 06:39 PM
  4. Analyze a string of words
    By zoe in forum Advanced Java
    Replies: 2
    Last Post: 07-26-2007, 10:01 AM
  5. Aspose.Words for Java - 2.1.0.0
    By levent in forum Java Software
    Replies: 0
    Last Post: 05-24-2007, 10:08 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •