 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
asianguy908 Master Cheater
Reputation: 0
Joined: 02 Jan 2008 Posts: 278
|
Posted: Thu Apr 17, 2008 11:15 pm Post subject: [Need help] Making an anagram with Java |
|
|
Hi there. I'm very new to the programming world and all its neat little tricks. Basically, I'm taking a course called Intro to Programming, where we are learning Java. We just started spring quarter, so I have not been taught many things. Some things we have learned include ints, doubles, strings, and whileloops (whileloops being the latest).
I have this homework assignment that requires me to create a class Anagram and methods getWord, makeAnagram, and makePuzzle. I have successfully created a method called getWord, which gets a word from a "dictionary" of words that I have assigned (namely the 50 states for this assignment). *Our teacher basically handed this to us, so nothing hard on my part*
The problem I have however, is making an anagram from this word. Our teacher gave us this code, which is supposed to get a random word, or integer in this case.
| Quote: |
java.util.Random r = new java.util.Random();
int whichWord = r.nextInt( dictionary.length ); |
I have an idea on how to create this method makeAnagram. I would have to create a new String called "result" which would return the anagram from the state I got from getWord. The problem for me is doing is. I have very limited knowledge of Java and this is my first language, so I don't know C, C++, or anything [HTML doesn't count].
Anyways, if someone would be kind as to help me or point me in the right direction, I would really appreciate it. Also the homework is due on Sunday...so I'm kind of on a schedule. You can also PM me or something and I will provide you with my AIM or MSN, whichever is more convenient for you. Thank you for taking the time to read. THANKS!
EDIT: Also, I forgot to say that we haven't learned what "public" does... We just create methods with "static type variable" if that matters at all =\.
|
|
| Back to top |
|
 |
Aikos Cheater
Reputation: 0
Joined: 26 Nov 2007 Posts: 47
|
Posted: Fri Apr 18, 2008 6:04 am Post subject: |
|
|
| Wiccaan wrote: | This section is not a 'do my homework', 'make my program', etc. section. Instead, it is a support section for people that actually want to learn how to attempt to program.
|
Just shuffle the contents of the string you get from GetWord and then store it in result and then return it? As simple as that?
|
|
| Back to top |
|
 |
asianguy908 Master Cheater
Reputation: 0
Joined: 02 Jan 2008 Posts: 278
|
Posted: Fri Apr 18, 2008 12:13 pm Post subject: |
|
|
I understand that this section is not a 'do my homework' or anything of that sort. I am not asking you to complete my homework. I can figure it out myself, but I'm at a roadblock. We're supposed to use substrings and I guess append a random letter from getWord to the result. We have to use a whileloop to complete this, but I don't know how to pull this off. I get the concept, but I don't exactly know how to put this down in code. I tried looking at random sources online but was unable to find any.
Oh well, thanks for the help anyways. We don't really know how to "shuffle" letters yet. I'm supposed to use substrings, whileloops to complete this task =\.
|
|
| Back to top |
|
 |
HalfPrime Grandmaster Cheater
Reputation: 0
Joined: 12 Mar 2008 Posts: 532 Location: Right there...On your monitor
|
Posted: Fri Apr 18, 2008 2:54 pm Post subject: |
|
|
| return += string.substr(random int from 1-string length);
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|