/** * Initializes a random M-by-N board, according to the frequency of letters in the English * language. * * @param M the number of rows * @param N the number of columns */ public BoggleBoard(int M, int N) { this.M = M; this.N = N; if (M <= 0) { throw new IllegalArgumentException("number of rows must be a positive integer"); } if (N <= 0) { throw new IllegalArgumentException("number of columns must be a positive integer"); } board = new char[M][N]; for (int i = 0; i < M; i++) { for (int j = 0; j < N; j++) { int r = StdRandom.discrete(FREQUENCIES); board[i][j] = ALPHABET.charAt(r); } } }