As requested Dealer class:
import java.util.*;
import java.io.*;
public class Dealer implements Serializable {
static int[] letterDist =
{18,4,4,8,24,4,6,4,18,2,2,8,4,12,16,4,2,12,8,12,8,4,4,2,4,2,4};
static Vector bag; // the tile bank of Integer objects
static int bagQuant=0; // tracks number in bag ZERO HERE FOR TESTING
static int[] hand; // holds 7 ints removed from bag
static int[][][] grid; // holds info on boosters & the old letters on the
board
static final int L1=1; // score booster constants
static final int L2=2;
static final int L3=3;
static final int L4=4;
static final int W2=12;
static final int W3=13;
static final int W4=14;
static final int DIM=20; // board grid size (from 0-DIM inc.)
public Dealer() {
if(bagQuant<7) {E.o("bag was empty so filling");gridInit(); resetBag();}
extract();
E.o("New Dealer successful");
}
public void gridInit() { // Called at beginning of game only
grid = new int [2][][];
grid[1] = new int [DIM+1][DIM+1]; // blank board
grid[0] = new int [][] { // score boosters
{W4,L1,L1,L1,L1,L3,L1,L1,L1,L1,W4,L1,L1,L1,L1,L3,L1,L1,L1,L1,W4},
{L1,W3,L1,L1,L1,L1,L1,L4,L1,L1,L1,L1,L1,L4,L1,L1,L1,L1,L1,W3,L1},
{L1,L1,W3,L1,L1,L1,L1,L1,L1,L1,L1,L1,L1,L1,L1,L1,L1,L1,W3,L1,L1},
{L1,L1,L1,W3,L1,L1,L2,L1,L1,L1,L3,L1,L1,L1,L2,L1,L1,W3,L1,L1,L1},
{L1,L1,L1,L1,W2,L1,L1,L1,L3,L1,L1,L1,L3,L1,L1,L1,W2,L1,L1,L1,L1},
{L3,L1,L1,L1,L1,W2,L1,L1,L1,L2,L1,L2,L1,L1,L1,W2,L1,L1,L1,L1,L3},
{L1,L1,L1,L2,L1,L1,W2,L1,L1,L1,L2,L1,L1,L1,W2,L1,L1,L2,L1,L1,L1},
{L1,L4,L1,L1,L1,L1,L1,W2,L1,L1,L1,L1,L1,W2,L1,L1,L1,L1,L1,L4,L1},
{L1,L1,L1,L1,L3,L1,L1,L1,L3,L1,L1,L1,L3,L1,L1,L1,L3,L1,L1,L1,L1},
{L1,L1,L1,L1,L1,L2,L1,L1,L1,L2,L1,L2,L1,L1,L1,L2,L1,L1,L1,L1,L1},
{W4,L1,L1,L3,L1,L1,L2,L1,L1,L1,W2,L1,L1,L1,L2,L1,L1,L3,L1,L1,W4},
{L1,L1,L1,L1,L1,L2,L1,L1,L1,L2,L1,L2,L1,L1,L1,L2,L1,L1,L1,L1,L1},
{L1,L1,L1,L1,L3,L1,L1,L1,L3,L1,L1,L1,L3,L1,L1,L1,L3,L1,L1,L1,L1},
{L1,L4,L1,L1,L1,L1,L1,W2,L1,L1,L1,L1,L1,W2,L1,L1,L1,L1,L1,L4,L1},
{L1,L1,L1,L2,L1,L1,W2,L1,L1,L1,L2,L1,L1,L1,W2,L1,L1,L2,L1,L1,L1},
{L3,L1,L1,L1,L1,W2,L1,L1,L1,L2,L1,L2,L1,L1,L1,W2,L1,L1,L1,L1,L3},
{L1,L1,L1,L1,W2,L1,L1,L1,L3,L1,L1,L1,L3,L1,L1,L1,W2,L1,L1,L1,L1},
{L1,L1,L1,W3,L1,L1,L2,L1,L1,L1,L3,L1,L1,L1,L2,L1,L1,W3,L1,L1,L1},
{L1,L1,W3,L1,L1,L1,L1,L1,L1,L1,L1,L1,L1,L1,L1,L1,L1,L1,W3,L1,L1},
{L1,W3,L1,L1,L1,L1,L1,L4,L1,L1,L1,L1,L1,L4,L1,L1,L1,L1,L1,W3,L1},
{W4,L1,L1,L1,L1,L3,L1,L1,L1,L1,W4,L1,L1,L1,L1,L3,L1,L1,L1,L1,W4},
};
}
public void resetBag() { // Initialise bag Vector and populate with new Tiles
bag = new Vector(); // Called at beginning of game only
for(int i=0;i<=26;i++) {
for(int j=0;j<letterDist[i];j++) {
Integer temp = new Integer(i); // create new Integer object from int i
bag.addElement(temp);
}
}
bagQuant = bag.size();
E.o("bagQuant = "+bagQuant);
}
public void extract() { // remove 7 tiles from bag vector at random and store
in array
hand = new int[7]; // initialise hand ready to receive
for(int i=0;i<7;i++) {
int pos = (int)(Math.random()*bag.size()); //get random tile
hand[i] = ((Integer)(bag.elementAt(pos))).intValue(); //update hand
E.o("extracted ~ "+bag.elementAt(pos));
bag.removeElementAt(pos); //update bag
}
bagQuant = bag.size();
E.o("bagQuant = "+bagQuant);
}
}
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html