Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[Need help] Making an anagram with Java

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
asianguy908
Master Cheater
Reputation: 0

Joined: 02 Jan 2008
Posts: 278

PostPosted: Thu Apr 17, 2008 11:15 pm    Post subject: [Need help] Making an anagram with Java Reply with quote

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
View user's profile Send private message
Aikos
Cheater
Reputation: 0

Joined: 26 Nov 2007
Posts: 47

PostPosted: Fri Apr 18, 2008 6:04 am    Post subject: Reply with quote

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
View user's profile Send private message
asianguy908
Master Cheater
Reputation: 0

Joined: 02 Jan 2008
Posts: 278

PostPosted: Fri Apr 18, 2008 12:13 pm    Post subject: Reply with quote

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
View user's profile Send private message
HalfPrime
Grandmaster Cheater
Reputation: 0

Joined: 12 Mar 2008
Posts: 532
Location: Right there...On your monitor

PostPosted: Fri Apr 18, 2008 2:54 pm    Post subject: Reply with quote

return += string.substr(random int from 1-string length);
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites