Skip to content

Commit

Permalink
some small improvements
Browse files Browse the repository at this point in the history
some small improvements and comments
  • Loading branch information
willyoung366 committed Dec 7, 2024
1 parent 174518c commit 94d74f0
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void drawElement(@NotNull Graphics2D graphics2D) {
int intValue = ((MinesweeperCell) puzzleElement).getData().data();

final String value = String.valueOf(intValue);
if(intValue== 1) {
if(intValue == 1) {
Color MSBLUE = new Color(7,3,251);
graphics2D.setColor(MSBLUE);
} else if(intValue == 2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public MineOrEmptyCaseRule() {
super(
"MINE-CASE-0001",
"Mine or Empty",
"An unset cell can either be a mine or filled.",
"An unset cell can either be a mine or empty.",
"edu/rpi/legup/images/minesweeper/cases/MineOrEmpty.png");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ public static void setUp() {
minesweeper = new Minesweeper();
}

// tests the finish with empty direct rule is many different cases

@Test
public void FinishWithEmptyDirectRule_OneUnsetOneEmptyOneClueTest1()
public void FinishWithEmptyDirectRule_OneUnsetOneEmptyOneNumberTest1()
throws InvalidFileFormatException {
TestUtilities.importTestBoard("puzzles/minesweeper/rules/3x3test8.txt", minesweeper);
TreeNode rootNode = minesweeper.getTree().getRootNode();
Expand Down Expand Up @@ -58,7 +60,7 @@ public void FinishWithEmptyDirectRule_OneUnsetOneEmptyOneClueTest1()
}

@Test
public void FinishWithEmptyDirectRule_FiveUnsetOneEmptyOneClueTest2()
public void FinishWithEmptyDirectRule_FiveUnsetOneEmptyOneNumberTest2()
throws InvalidFileFormatException {
TestUtilities.importTestBoard("puzzles/minesweeper/rules/3x3test9.txt", minesweeper);
TreeNode rootNode = minesweeper.getTree().getRootNode();
Expand Down Expand Up @@ -88,7 +90,7 @@ public void FinishWithEmptyDirectRule_FiveUnsetOneEmptyOneClueTest2()
}

@Test
public void FinishWithEmptyDirectRule_NineUnsetOneEmptyZeroCluesTest3()
public void FinishWithEmptyDirectRule_NineUnsetOneEmptyZeroNumbersTest3()
throws InvalidFileFormatException {
TestUtilities.importTestBoard("puzzles/minesweeper/rules/3x3test", minesweeper);
TreeNode rootNode = minesweeper.getTree().getRootNode();
Expand Down Expand Up @@ -118,7 +120,7 @@ public void FinishWithEmptyDirectRule_NineUnsetOneEmptyZeroCluesTest3()
}

@Test
public void FinishWithEmptyDirectRule_NineUnsetNineEmptyZeroCluesTest4()
public void FinishWithEmptyDirectRule_NineUnsetNineEmptyZeroNumbersTest4()
throws InvalidFileFormatException {
TestUtilities.importTestBoard("puzzles/minesweeper/rules/3x3test", minesweeper);
TreeNode rootNode = minesweeper.getTree().getRootNode();
Expand Down Expand Up @@ -176,7 +178,7 @@ public void FinishWithEmptyDirectRule_NineUnsetNineEmptyZeroCluesTest4()
}

@Test
public void FinishWithEmptyDirectRule_OneUnsetOneEmptyThreeCluesTest5()
public void FinishWithEmptyDirectRule_OneUnsetOneEmptyThreeNumbersTest5()
throws InvalidFileFormatException {
TestUtilities.importTestBoard("puzzles/minesweeper/rules/3x3test10.txt", minesweeper);
TreeNode rootNode = minesweeper.getTree().getRootNode();
Expand Down Expand Up @@ -206,7 +208,7 @@ public void FinishWithEmptyDirectRule_OneUnsetOneEmptyThreeCluesTest5()
}

@Test
public void FinishWithEmptyDirectRule_OneUnsetOneEmptyThreeCluesTest6()
public void FinishWithEmptyDirectRule_OneUnsetOneEmptyThreeNumbersTest6()
throws InvalidFileFormatException {
TestUtilities.importTestBoard("puzzles/minesweeper/rules/3x3test11.txt", minesweeper);
TreeNode rootNode = minesweeper.getTree().getRootNode();
Expand Down Expand Up @@ -236,7 +238,7 @@ public void FinishWithEmptyDirectRule_OneUnsetOneEmptyThreeCluesTest6()
}

@Test
public void FinishWithEmptyDirectRule_FiveUnsetTwoEmptyTwoCluesTest7()
public void FinishWithEmptyDirectRule_FiveUnsetTwoEmptyTwoNumbersTest7()
throws InvalidFileFormatException {
TestUtilities.importTestBoard("puzzles/minesweeper/rules/3x3test12.txt", minesweeper);
TreeNode rootNode = minesweeper.getTree().getRootNode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ public static void setUp() {
minesweeper = new Minesweeper();
}

// tests the finish with mines direct rule is many different cases

@Test
public void FinishWithMinesDirectRule_OneUnsetOneBombOneClueTest1()
public void FinishWithMinesDirectRule_OneUnsetOneBombOneNumberTest1()
throws InvalidFileFormatException {
TestUtilities.importTestBoard("puzzles/minesweeper/rules/3x3test2.txt", minesweeper);
TreeNode rootNode = minesweeper.getTree().getRootNode();
Expand Down Expand Up @@ -55,7 +57,7 @@ public void FinishWithMinesDirectRule_OneUnsetOneBombOneClueTest1()
}

@Test
public void FinishWithMinesDirectRule_FourUnsetOneBombOneClueTest2()
public void FinishWithMinesDirectRule_FourUnsetOneBombOneNumberTest2()
throws InvalidFileFormatException {
TestUtilities.importTestBoard("puzzles/minesweeper/rules/3x3test3.txt", minesweeper);
TreeNode rootNode = minesweeper.getTree().getRootNode();
Expand Down Expand Up @@ -86,7 +88,7 @@ public void FinishWithMinesDirectRule_FourUnsetOneBombOneClueTest2()


@Test
public void FinishWithMinesDirectRule_FourUnsetFourBombsOneClueTest3()
public void FinishWithMinesDirectRule_FourUnsetFourBombsOneNumberTest3()
throws InvalidFileFormatException {
TestUtilities.importTestBoard("puzzles/minesweeper/rules/3x3test3.txt", minesweeper);
TreeNode rootNode = minesweeper.getTree().getRootNode();
Expand Down Expand Up @@ -126,7 +128,7 @@ public void FinishWithMinesDirectRule_FourUnsetFourBombsOneClueTest3()
}

@Test
public void FinishWithMinesDirectRule_EightUnsetEightBombsOneClueTest4()
public void FinishWithMinesDirectRule_EightUnsetEightBombsOneNumberTest4()
throws InvalidFileFormatException {
TestUtilities.importTestBoard("puzzles/minesweeper/rules/3x3test4.txt", minesweeper);
TreeNode rootNode = minesweeper.getTree().getRootNode();
Expand Down Expand Up @@ -180,7 +182,7 @@ public void FinishWithMinesDirectRule_EightUnsetEightBombsOneClueTest4()
}

@Test
public void FinishWithMinesDirectRule_OneUnsetOneBombFourCluesTest5()
public void FinishWithMinesDirectRule_OneUnsetOneBombFourNumbersTest5()
throws InvalidFileFormatException {
TestUtilities.importTestBoard("puzzles/minesweeper/rules/3x3test5.txt", minesweeper);
TreeNode rootNode = minesweeper.getTree().getRootNode();
Expand Down Expand Up @@ -210,7 +212,7 @@ public void FinishWithMinesDirectRule_OneUnsetOneBombFourCluesTest5()
}

@Test
public void FinishWithMinesDirectRule_TwoUnsetTwoBombsTwoCluesTest6()
public void FinishWithMinesDirectRule_TwoUnsetTwoBombsTwoNumbersTest6()
throws InvalidFileFormatException {
TestUtilities.importTestBoard("puzzles/minesweeper/rules/3x3test6.txt", minesweeper);
TreeNode rootNode = minesweeper.getTree().getRootNode();
Expand Down Expand Up @@ -243,7 +245,7 @@ public void FinishWithMinesDirectRule_TwoUnsetTwoBombsTwoCluesTest6()
}

@Test
public void FinishWithMinesDirectRule_ThreeUnsetOneBombTwoCluesTest7()
public void FinishWithMinesDirectRule_ThreeUnsetOneBombTwoNumbersTest7()
throws InvalidFileFormatException {
TestUtilities.importTestBoard("puzzles/minesweeper/rules/3x3test7.txt", minesweeper);
TreeNode rootNode = minesweeper.getTree().getRootNode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static void setUp() {

/**
* Tests the Mine or Empty case rule by ensuring that it results in two children, that contain
* a modified cell that is either black or white
* a modified cell that is either mine or empty
*/
@Test
public void MineOrEmptyCaseRuleTest1()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public static void setUp() {
minesweeper = new Minesweeper();
}

// Horizontal/vertical tests means the adjacent number cells are adjacent horizontally/vertically

@Test
public void NonTouchingSharedEmptyDirectRule_HorizontalTest1()
throws InvalidFileFormatException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public static void setUp() {
minesweeper = new Minesweeper();
}

// Horizontal/vertical tests means the adjacent number cells are adjacent horizontally/vertically

@Test
public void NonTouchingSharedMineDirectRule_HorizontalTest1()
throws InvalidFileFormatException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static void setUp() {
/**
* Tests the Satisfy Number case rule by ensuring that it results in all possibilities
* for the number. This case tests a number 2 with three unset cells around it, so each
* case must a different arrangement of two bombs and one empty.
* case must replace the unset tiles with a different arrangement of two bombs and one empty.
*/
@Test
public void SatisfyNumberCaseRuleTest1()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public void TooManyMinesTest1() throws InvalidFileFormatException {
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(1, 0)));
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(2, 0)));
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(0, 1)));
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(2, 1)));
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(0, 2)));
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(1, 2)));
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(2, 1)));
Expand All @@ -63,6 +64,7 @@ public void TooManyMinesTest2() throws InvalidFileFormatException {
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(1, 0)));
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(2, 0)));
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(0, 1)));
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(2, 1)));
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(0, 2)));
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(1, 2)));
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(2, 1)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ public void TooManyMinesTest1() throws InvalidFileFormatException {
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(1, 0)));
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(2, 0)));
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(0, 1)));
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(2, 1)));
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(0, 2)));
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(1, 2)));
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(2, 1)));
Assert.assertNotNull(RULE.checkContradictionAt(board, board.getCell(2, 2)));
}
}

0 comments on commit 94d74f0

Please sign in to comment.