import java.io.*;

/** Simulate the rolling of a dice 100 times */
public class RollDice {
  public static void main(String[] args) {

    final int ROLLS= 100;  //No. of rolls of dice d
    Dice d= new Dice();    //Dice d to roll
    int faceUp;            //Face that dice d shows
    //result[i] is frequency of outcome i
      int[] result= new int[Dice.SIDES+1];
    
    //Roll dice ROLLS times
      for (int i=0; i<ROLLS; i++) {
        //roll dice
          d.roll();
          faceUp= d.getFace();
        //update frequency array
          result[faceUp]= result[faceUp] + 1;
      }
  }

  /** Simulate rolling of dice numTrials times. 
   *  This method uses class FileOutput for writing data
   *  to a file.  You do NOT need to learn about writing data files
   *  or about throwing exceptions right now. */
  public static void simulate(int numTrials) throws IOException {

    //result[i] is the frequency of getting side i
      int[] result= new int[Dice.SIDES+1];  

    //Roll dice numTrials times
      for (int i=0; i<numTrials; i++) {
        //roll dice and update frequency array
          result[new Dice().getFace()]++;
      }
            
    //Save data to file
      FileOutput.copyIntVec(result);
  }
}

/** A six-sided dice */
class Dice {
  public static final int SIDES= 6;  //no. of sides on a dice
  private int face;  //Face that is shown currently
  
  /** Constructor: Dice's face has a random value in 1..SIDES */
  public Dice() { roll(); }
  
  /** face gets a random value in 1..SIDES */
  public void roll() {
    face= (int) (Math.random()*SIDES+1);
  }
  
  /** = Get face currently shown */
  public int getFace() { return face; }
}

