public class Dice
{
int player;
int computer;
public static void main (String[]args)
{
player = 1 + (int)((Math.random()*7));
computer = 1 + (int)((Math.random()*7));
diceRoll();
System.out.println("You rolled a " + player);
System.out.println("Computer rolled a " + computer);
System.out.println("And the winner is" + winner);
}
public static void diceRoll()
{
boolean winner = player > computer;
if (winner)
System.out.println("You won!");
if (!winner)
System.out.println("You lost!");
}
Sorry... this might be stupid question but I am very beginner to java
I am supposed to create a dice roll game. The rule is simple, if computer has larger number than the player, then the computer wins, and if player has larger number, then the player wins. I have to create this by using If statement..
But I am getting the error saying that "non static variable cannot be referenced from a static context" and also I got the error saying " cannot find the symbol winner"
I don't know how to do this..
Thank you so much for your help..