|
|
Welcome to the Java Forums.
You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:
- have access to post topics
- communicate privately with other members (PM)
- not see advertisements between posts
- have the possibility to earn one of our surprises if you are an active member
- access many other special features that will be introduced later.
Registration is fast, simple and absolutely free so please, join our community today!
If you have any problems with the registration process or your account login, please contact us.
|
|

04-28-2008, 06:46 AM
|
|
Member
|
|
Join Date: Apr 2008
Posts: 5
|
|
|
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
|
|

04-28-2008, 07:08 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,403
|
|
|
How about randomly generate characters and build the string?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. (Close on July 13, 2008)
|
|

04-28-2008, 07:47 AM
|
|
Member
|
|
Join Date: Apr 2008
Posts: 5
|
|
|
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.
|
|

04-28-2008, 08:02 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,403
|
|
|
What you mean a word bank? You mean you have a bunch of scramble words with you? If so it is too easy.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. (Close on July 13, 2008)
|
|

04-28-2008, 08:31 AM
|
 |
Senior Member
|
|
Join Date: Apr 2008
Posts: 354
|
|
|
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
|
|

04-28-2008, 08:36 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,403
|
|
|
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.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. (Close on July 13, 2008)
|
|

04-28-2008, 08:48 AM
|
 |
Senior Member
|
|
Join Date: Apr 2008
Posts: 354
|
|
|
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
|
|

04-28-2008, 09:01 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,403
|
|
Don't worry pal. Anytime anyone can make mistakes. 
Don't worry.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. (Close on July 13, 2008)
|
|

04-29-2008, 09:30 PM
|
 |
Member
|
|
Join Date: Apr 2008
Posts: 1
|
|
|
Scrambling String
Originally Posted by Shadow22202
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:
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
__________________
Alex Roldan HD.
Parquesoft - Cali, Colombia
Last edited by aleshivan : 04-29-2008 at 09:49 PM.
Reason: Corrección de estilo
|
|

04-30-2008, 04:51 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,403
|
|
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.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. (Close on July 13, 2008)
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|