CS110 Project –– Boggle
Phase 2: Due Monday, April 15th.
10% extra credit for submissions received by end of day Friday, April 12th
60 points, Complete javadocs documentation required. Submit ALL files required to run your project in one zip file.
I have provided the BoggleText class that will be the controller that provides the connection between the model (the game) and the view (the console I/O). Your Game class must work with the provided class and should provide output similar to the output provided below. You may tweak the classes submitted for Phase I, however, you should NOT need to make major changes.
Implementation – Phase II
Using the classes implemented in Part I, and the BoggleText class provided with this assignment, you will create a fully functional Game of Boggle with console I/O. Your Game class will implement all aspects of the game (but NOT user interface – your Game class does NOT handle user input/output).
Look carefully at the code in BoggleText class. This will determine the minimum public interface your Game class must provide. I have highlighted some areas of interest.
BoggeText.java
import java.util.ArrayList;
import java.util.Scanner;
public class BoggleText {
public static void main(String[] args) {
// create game
Game g = new Game();
// create scanner for user input
Scanner keyboard = new Scanner(System.in);
// variables for user input
int row, col;
String input;
// create flag to end game
boolean stop = false;
while (!stop) {
// print board
System.out.println(g);
// prompt user for choices
System.out.print(“(s)elect, (d)eselect, (l)ist selected, ” +
“(c)lear selected, (t)est selected, (e)nd: “);
// get choice
input = keyboard.nextLine();
// select
if (input.equalsIgnoreCase(“s”)) {
// prompt for row & column
System.out.print(“row / column [r c]: “);
// get row, col from input
row = keyboard.nextInt();
col = keyboard.nextInt();
input = keyboard.nextLine(); // clr new line left in buffer
// test if the r/c combination is a valid move
if (g.isValidSelection(row, col)){
// add tile to selected tiles
g.addToSelected(row, col);
}
else {
System.out.println(“Invalid selection! Please select ” +
“a letter adjacent to the previously ” +
“selected letter.”);
} }
// deselect
else if (input.equalsIgnoreCase(“d”)) {
// prompt for row & column
System.out.print(“row / column [r c]: “);
// get row, col from input
row = keyboard.nextInt();
col = keyboard.nextInt();
input = keyboard.nextLine(); // clr new line left in buffer
// remove tile from selected tiles
g.removeFromSelected(row,col);
}
// list currently selected tiles
else if (input.equalsIgnoreCase(“l”)) {
ArrayList
System.out.println(selected);
}
// clear currently selected tiles
else if (input.equalsIgnoreCase(“c”)) {
g.clearSelected();
}
else if (input.equalsIgnoreCase(“t”)) {
g.testSelected();
}
// end game
else if (input.equalsIgnoreCase(“e”)) {
stop = true; }
} }
}
Sample Run
EEST Qu E T A AIIE DYNT
selected[]
words: []
score: 0
(s)elect, (d)eselect, (l)ist selected, (c)lear selected, (t)est selected, (e)nd: s
row / column [r c]: 1 0 EEST
Qu E T A AIIE DYNT
selected[Qu]
words: []
score: 0
(s)elect, (d)eselect, (l)ist selected, (c)lear selected, (t)est selected, (e)nd: s
row / column [r c]: 2 0 EEST
Qu E T A AIIE DYNT
selected[Qu, A]
words: []
score: 0
(s)elect, (d)eselect, (l)ist selected, (c)lear selected, (t)est selected, (e)nd: s
row / column [r c]: 3 0
EEST Qu E T A AIIE DYNT
selected[Qu, A, D]
words: []
score: 0
(s)elect, (d)eselect, (l)ist selected, (c)lear selected, (t)est selected, (e)nd: t
EEST Qu E T A AIIE DYNT
selected[]
words: [QUAD]
score: 1
(s)elect, (d)eselect, (l)ist selected, (c)lear selected, (t)est selected, (e)nd: s
row / column [r c]: 2 3 EEST
Qu E T A AIIE DYNT
selected[E]
words: [QUAD]
score: 1
(s)elect, (d)eselect, (l)ist selected, (c)lear selected, (t)est selected, (e)nd: s
row / column [r c]: 1 3 EEST
Qu E T A
AIIE DYNT
selected[E, A]
words: [QUAD]
score: 1
(s)elect, (d)eselect, (l)ist selected, (c)lear selected, (t)est selected, (e)nd: s
row / column [r c]: 0 3 EEST
Qu E T A AIIE DYNT
selected[E, A, T]
words: [QUAD]
score: 1
(s)elect, (d)eselect, (l)ist selected, (c)lear selected, (t)est selected, (e)nd: t
EEST Qu E T A AIIE DYNT
selected[]
words: [QUAD, EAT]
score: 2
(s)elect, (d)eselect, (l)ist selected, (c)lear selected, (t)est selected, (e)nd: s
row / column [r c]: 0 0 EEST
Qu E T A AIIE DYNT
selected[E]
words: [QUAD, EAT]
score: 2
(s)elect, (d)eselect, (l)ist selected, (c)lear selected, (t)est selected, (e)nd: s
row / column [r c]: 2 0
Invalid selection! Please select a letter adjacent to the previously selected letter.
EEST Qu E T A AIIE DYNT
selected[E]
words: [QUAD, EAT]
score: 2
(s)elect, (d)eselect, (l)ist selected, (c)lear selected, (t)est selected, (e)nd: d
row / column [r c]: 0 0 EEST
Qu E T A AIIE DYNT
selected[]
words: [QUAD, EAT]
score: 2
(s)elect, (d)eselect, (l)ist selected, (c)lear selected, (t)est selected, (e)nd: d
row / column [r c]: 0 1 EEST
Qu E T A AIIE DYNT
selected[]
words: [QUAD, EAT]
score: 2
(s)elect, (d)eselect, (l)ist selected, (c)lear selected, (t)est selected, (e)nd: e