import java.util.Random;
public class Spinner
{
  protected int numValues;
  protected int currentValue;
  protected Random ran;

  public Spinner() 
  {
    numValues = 6;
    currentValue = 1;
    ran = new Random();
  }

  public Spinner(int numValues, int currentValue)
  {
    if (numValues < 1 || currentValue < 1 || currentValue > numValues)
    {
      System.out.println("Bad parameter value");
      System.exit(1);
    }
    else
    {
      this.numValues = numValues;
      this.currentValue = currentValue;
    }
    ran = new Random();
  }

  public int getCurrentValue()
  {
    return currentValue;
  }

  public int spin()
  {
    currentValue = ran.nextInt(numValues);
    currentValue = currentValue + 1;
    return currentValue;
  }

  public String toString()
  {
    return "The arrow is pointing to " + getCurrentValue();
  }

  public static void main(String args[])
  {
    Spinner s = new Spinner(10, 1);
    int counts[] = new int[11];
    int val;
    int sum = 0;
    for (int i = 0; i < 11; i++)
      counts[i] = 0;

    for (int i = 0; i < 1000; i++)
    {
      val = s.spin();
      counts[val]++;
      sum = sum + val;
    }
    double ave = (double)sum / (double)1000;
    for (int i = 1; i < 11; i++)
    {
      System.out.println(i + "   " + counts[i]);
    }
    System.out.println("The average is " + ave);
  }
}

