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 }
Code:import java.io.*; import java.util.*; 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 { String string_1; 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); getUserInput(); } public void getUserInput() { computer = getRandom(); switch(computer) { case ROCK: if (player === SCISSORS ) { System.out.println("Computer Wins"); break; } else if (player == PAPER) { System.out.println("Player WINS"); break; } else { System.out.println("Tie"); break; } } } public int getRandom() { return (int)(Math.random()*3)+1; } }


Reply With Quote


Bookmarks