Sign in to follow this  

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

This topic is 2787 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

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

This topic is 2787 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this