Stumped on program project
I am trying to writing a program that does the Rock Paper Scissor game, against the computer
using keyboard input, and the buffered reader. also keeping track of wins, loses, ties
I managed to get the input through the buffered reader, the problem is I am stumped on what the next step is. any help would be appreciated.
also when compiling I get these two errors:
rps2.java: 44: illegal start of expression else if(player === PAPER)
rps2.java:59: ')' expected }
public class rps2
final int ROCK = 0, PAPER = 1, SCISSORS = 2;
int computer, player;
int COMP = 0, PLAYER = 0;
int Cwins, Closses, Pwins, Plosses,ties, winner = 0;
public static void main (String  args)throws IOException
System.out.println("Enter *0*-Rock | *1* Paper | *2*Scissors : ");
BufferedReader stdin =
new BufferedReader( new InputStreamReader(System.in));
string_1 = stdin.readLine();
int player = Integer.parseInt(string_1);
public void getUserInput()
computer = getRandom();
if (player === SCISSORS )
else if (player == PAPER)
public int getRandom()
When checking equality, you're using 3 '=' rather than 2 i.e. '===' rather than '=='.
The methods getUserInput() and getRandom() should be declared static as a static method (such as main) cannot directly call a non-static one.
All of your instance variables must be declared static because once you've made getUserInput() static, they cannot be referenced from a static method.
Also it's a convention in Java to declare classes with a capital letter i.e. 'RockPaperScissor' rather than 'rockpaperscissor' or 'rps'.
It's also not a good idea to name variables such as 'string_1' - the name isn't very helpful.
Unless variables are to be used outside a class (such as 'ROCK') they should be declared private.
thanks for advice and tips ArchAngel much appreciated
i am still learning the conventions of java,
the static is what i am having a problem with though.
so the variables should be
int static computer
No, you have the wrong syntax:
'static' BEFORe 'int'.
private static int computer;
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center