Jump to content
  • Advertisement
Sign in to follow this  
metallicsoul92

[java] Just starting out, my first game program...

This topic is 3003 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

is kinda messed up. http://pastebin.com/rN3Ut6q5 like, when i try to play it, the computers choice is always higher than 1-3 does anyone know how i could fix that?

Share this post


Link to post
Share on other sites
Advertisement
It is not that the computer's choice is always higher than 1-3, it is yours the one that is higher than 3.

You can check it:
System.out.println("choice: " + choice);
System.out.println("cc: " + cc);
System.out.println("test fuck up?");

The quick solution is:
choice = Character.getNumericValue(bufRead.read());

The reason is that what you are getting with read() is the Unicode value.
In short: every symbol has a number associated with it,
e.g:
a=97
b=98
...
A=65
B=66
...
0=48
1=49
...
etc..
So when you choose 1, what you are putting in choice var is the number 49, you need to "translate" it with Character.getNumericValue

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!