
/* 
 *  The goal of this mini-program is to test how java.util.Random
 *  works so that I can use it in Minesweeper.
 *
 *  Basically, I am going to create a for loop and print out 10
 *  random numbers.
 */

public class RandomTest {


  private java.util.Random randomizer_;
  private int ITERATIONS = 10; // change if want more iterations

  /*
   * Since we are making a non-applet, we need a main function
   * that instantiates my random class
   */
  public static void main(String [] argv){
    new RandomTest();
  }

  public RandomTest(){

    randomizer_ = new java.util.Random();
    this.printRandomNumbers();

  }

  public void printRandomNumbers(){
    
    double randomDouble;
    int randomInt;
    
    for (int i=0; i<ITERATIONS; i++){
      /* I found that the best method to use on Random would be
       * the nextDouble method.  This will return a number between
       * 0.0 and 1.0. 
       */
      randomDouble = randomizer_.nextDouble();
      /* In order to get it to be an integer between 0 and 100, 
       * I need to mutiply my double by 100.  I also need to cast
       * it to an int because java likes explicit casting and I know
       * that I want an int
       */
      randomInt = (int)(randomDouble * 100);

      // this just prints out the iteration number and the randomInt
      System.out.println("iteration number " + i + " = " + randomInt);
    }


  }
}
