/********************************************************************
Class tileBag
 --holds tiles waiting to be drawn

Authors: Kristi Garner, Mary Garland    
CS406: Java and Internet Programming
*******************************************************************/
import java.awt.*;
import java.awt.image.*;
import java.awt.event.*;
import java.util.*;
import java.applet.*;
import java.net.*;
import java.applet.Applet;
import java.util.Random;

class tileBag{

  private static Random rand;
  // number of each letter 9,2,2,4,12,2,3,2,9,1,1,4,2,6,8,2,1,6,4,6,4,2,2,1,2,1
  private static char letters[] = {'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'b', 'b', 'c', 'c',
                            'd', 'd', 'd', 'd', 'e', 'e', 'e', 'e', 'e', 'e', 'e', 'e', 'e',
                            'e', 'e', 'e', 'f', 'f', 'g', 'g', 'g', 'h', 'h', 'i', 'i', 'i', 
                            'i', 'i', 'i', 'i', 'i', 'i', 'j', 'k', 'l', 'l', 'l', 'l', 'm',
                            'm', 'n', 'n', 'n', 'n', 'n', 'n', 'o', 'o', 'o', 'o', 'o', 'o',
                            'o', 'o', 'p', 'p', 'q', 'r', 'r', 'r', 'r', 'r', 'r', 's', 's',
                            's', 's', 't', 't', 't', 't', 't', 't', 'u', 'u', 'u', 'u', 'v',
                            'v', 'w', 'w', 'x', 'y', 'y', 'z'};
  private static char bag[] = new char[98];
  private static int intBag[] = new int[98];
  private static int counter = -1;
  private static int intCounter = -1;

  public tileBag()
  { 
    int total = 0;
    int r;
    int temp;

    while(total < 98) {

      r = (int)(Math.random() * 98); 

      if(letters[r] != '0') {
        bag[total] = letters[r];
        temp = (int)(letters[r]);
        intBag[total] = temp - 97;
        letters[r] = '0';
        total++;
      } // end if 

    } // end while
  } // end tileBag()


  public char nextLetter() {
    counter++;
    if(counter >= 98) {
      return '0';
    } else {
      return bag[counter];
    }
  }

  public int nextInt() {
    intCounter++;
    if(intCounter >= 98) {
      return -1;
    } else {
      return intBag[intCounter];
    }

  }
    

} // end class tileBag

