mercredi 28 septembre 2016

Error: Java symbol not found; called correctly

I'm doing an assignment for AP Computer Science at my high school. I am trying to simulate a game of Craps. The dice is supposed to return a random int between 1 and 6. The teacher looked at it and couldn't figure it out.

public class TestDie
{
   public static void main(String[] args)
   {
      Die die = new Die();
      die.roll();
      System.out.println(die.getNumDots());
      die.roll();
   }
}

Error: TestDie.java:7: error: cannot find symbol

System.out.println(die.getNumDots());

It is testing this, which compiles fine import java.lang.Math;

public class Die
{
   private int numDots;

   private void roll()
   {
   //double random = Math.random() * 50 + 1;
   numDots = (int )(Math.random() * 6 + 1);
   }

   public int getNumDots()
   {
   return numDots;
   }
}




Aucun commentaire:

Enregistrer un commentaire