Boggle 1: BoggleTray with foundInBoggleTray WebCat Turnin

Collaboration This project may be completed in a team of two if you agree to work in a pair programming mode ALL of the time. Otherwise, complete this solo. Section leader help is available for everyone.

Boggle the Game

Boggle is a word game designed by Allan Turoff and trademarked by Parker Brothers and Hasbro. The game of Boggle has a dice tray that can hold 16 dice that can be "rolled" to generate a random collection of 16 letters. Each six-sided die has letters from which players try to find words. Words are possible if letters line up next to each other horizontally, vertically, or diagonally without being reused. There are 3 letters that can be connected to any letter on a corner, 5 for the six letters on the borders and 8 for the middle four letters (there is no wraparound). To make up one word no letter may be used more than once. There is no Q, rather there is one die that written as Qu on the die. We will use Q to represent Qu so the following dice tray has the word quiet
A B C Q
T G I X
D E H J
K L M N /

Note: Other game details will be discussed in Iteration 2

Iteration 1: BoggleTray


As with other projects you are asked to first develop a well-tested model. To get started immediately begin with a type named BoggleTray that determines if a given String can be found in the collection of the current dice values using the rules of Boggle. BoggleTray must have these 2 methods:

public class BoggleTray {

// Constructor takes a 2D array of characters that represents the

// Boggle BoggleTray with 16 dice already rolled in a known fixed state.

public BoggleTray(char[][] array) {

// TODO: Complete this constructor

}

// Return true if str is found in the Boggle BoggleTray according to Boggle rules.

// Note: This method does NOT check to see if the word is in the list of words.

public boolean foundInBoggleTray(String str){

// TODO: Complete this method

return false;

}

}

Here is a start of a unit test java that asserts some strings can be found that begins in the upper left corner. After you get these working you can change foundInBoggleTray to try to find a word beginning at any of the 16 locations. Note: The tests need not check to see if the word is also in BoggleWords (you'll do that for class Boggle after you get this new type working).

// A unit test for class BoggleTray, which is one important part of the final project

//

// 1) YOUR NAME,

// 2) YOUR PARTNER'S NAME IF YOU AFREED TO WORK IN PAIR PROGRAMMING MODE WITH A PARTNER

//

import static org.junit.Assert.*;

import org.junit.Test;

public class BoggleTrayTest {

private char[][] tray = { // Always use upper case letters in the dice tray

{'A', 'B', 'C', 'D' },

{'E', 'F', 'G', 'H' },

{'I', 'J', 'K', 'L' },

{'M', 'N', 'O', 'P' } };

@Test

public void testStringFindWhenThereStartingInUpperLeftCorner() {

BoggleTray bt = new BoggleTray(tray);

assertTrue(bt.foundInBoggleTray("ABC"));

assertTrue(bt.foundInBoggleTray("abC")); // Must be case insensitive

assertTrue(bt.foundInBoggleTray("aBf"));

assertTrue(bt.foundInBoggleTray("abc"));

assertTrue(bt.foundInBoggleTray("ABCD"));

// ...

assertTrue(bt.foundInBoggleTray("ABFEJINM"));

assertTrue(bt.foundInBoggleTray("AbCdHgFeIjKLpONm"));

assertTrue(bt.foundInBoggleTray("ABCDHLPOKJNMIEFG"));

}

@Test

public void testStringFindWhenNotThere () {

BoggleTray bt = new BoggleTray(tray);

assertFalse(bt.foundInBoggleTray("acb"));

assertFalse(bt.foundInBoggleTray("AiE"));

// ...

}

@Test

public void testStringFindWhenAttemptIsMadeToUseALetterTwice () {

BoggleTray bt = new BoggleTray(tray);

assertFalse(bt.foundInBoggleTray("ABA"));

assertFalse(bt.foundInBoggleTray("ABB"));

assertFalse(bt.foundInBoggleTray("aEa"));

// ...

}

// More tests will be necessary

}

Grading Criteria (85 pts) via WebCat


___/ +80 For BoggleTray(char[][]) and foundInBoggleTray(String) for problem coverage as graded by WebCat. No Code coverage grading, but write your own tests!

-78 If foundInBoggleTray only returns true or false with no supporting logic as to why.