Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / October 2007

Tip: Looking for answers? Try searching our database.

Help

Thread view: 
f2prateek - 30 Oct 2007 17:11 GMT
I'm tryin to make a game in java which is like guessing the number.
eg:The number is 345 and the user enters lets say 123, so like the
program is supposed to return dat one digit was guessed correctly and
none were guessed correctly in their right positions. Can i get some
help please for the second part of the program. And also how i use the
random function to generate a different 3-duigit number.
Thanks a lot for your hep guys.
Lothar Kimmeringer - 30 Oct 2007 20:10 GMT
> I'm tryin to make a game in java which is like guessing the number.

Let me guess that the initial motivation is a piece of paper
giving you the rough idea and a date as deadline until is has
to be finished ;-)

> eg:The number is 345 and the user enters lets say 123, so like the
> program is supposed to return dat one digit was guessed correctly and
> none were guessed correctly in their right positions.

Here you have to ask yourself how the positions are counted.
If the number is 1234 and you guess 1 should it be seen as
1000 or 0001?.

> Can i get some
> help please for the second part of the program.

You should see the number as text instead of a number. Reading
the Javadoc for java.lang.String might give you ideas how to
solve this part of the homework.

> And also how i use the
> random function to generate a different 3-duigit number.

The necessary functions are grouped within java.lang.Math.
As well here, a look into the Javadocs will give you the
necessary ideas what methods are to be used.

In case you don't have the Javadoc at hand:

http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Math.html
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html

If you still need hints or help, feel free to come back with
more concrete questions.

Regards, Lothar
Signature

Lothar Kimmeringer                E-Mail: spamfang@kimmeringer.de
              PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81)

Always remember: The answer is forty-two, there can only be wrong
                questions!

Roedy Green - 31 Oct 2007 02:02 GMT
>I'm tryin to make a game in java which is like guessing the number.
>eg:The number is 345 and the user enters lets say 123, so like the
[quoted text clipped - 3 lines]
>random function to generate a different 3-duigit number.
>Thanks a lot for your hep guys.

You want to be able to take a number apart into digits.  This is very
similar to the task of converting it to a string.

In a loop both divide by 10 and take the remainder modulo 10. This
peels the digits off right to left.

Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Roedy Green - 31 Oct 2007 02:02 GMT
>I'm tryin to make a game in java which is like guessing the number.
>eg:The number is 345 and the user enters lets say 123, so like the
[quoted text clipped - 3 lines]
>random function to generate a different 3-duigit number.
>Thanks a lot for your hep guys.

see http://mindprod.com/jgloss/pseudorandom.html
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.