FIX ERROR in my code ,project guesser game ,code in description
this is a guessergame project, there are 5 objects , umpire ,guesser , player1 , player 2 and player3 . the umpire begins the game ,and the guesser is supposed to guess a number , the umpire collects it , then player 1 is suppose to guess the another number , and player 2 and player 3 ,, and umpire collects from all , if the number of any player matches with number of guesser , we have to print that , that individual player won the game else try again ,,,,,,,,, MY CODE IS RUNNING BUT WHY EVERYTIME PLAYER 1 IS WINNING ?? PLEASE FIX IT code below import java.util.*; class guessGame { int num,num1,num2,num3,number; public int guessNum(){ Scanner sc = new Scanner(System.in); int number = sc.nextInt(); return number; } public static void main (String args[]){ guessGame umpire = new guessGame(); guessGame guesser = new guessGame(); guessGame player1= new guessGame(); guessGame player2= new guessGame(); guessGame player3= new guessGame(); int num =guesser.guessNum(); int num1 =player1.guessNum(); int num2 = player2.guessNum(); int num3= player3.guessNum(); umpire.compare(); } public void compare(){ if(num==num1){ System.out.println("player 1 won the game "); }else if(num==num2){ System.out.println("player 2 won the game"); }else if (num==num3){ System.out.println("player 3 won the game "); } else{ System.out.println("game drawn "); } } }