Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 29 additions & 7 deletions minesweeper/src/main/java/edu/pdx/cs410J/katas/Minesweeper.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,37 @@

public class Minesweeper {

public Minesweeper(int row, int column) {
private char[][] inputBoard;
private char[][] outputBoard;

}
int rowsFilledIn = 0;

public void addRow(String row) {
public Minesweeper(int row, int column) throws ZeroSizedBoardException {
if (row == 0 || column == 0) {
throw new ZeroSizedBoardException();
}
this.inputBoard = new char[row][column];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting choice of data structure. I wonder if an ArrayList would be easier to work with.

}

}
public void addRow(String rowToCopy) throws RaggedBoardException {
if (rowToCopy.length() != inputBoard[0].length) {
throw new RaggedBoardException();
}

public String solve() {
return null;
}
if (rowsFilledIn == inputBoard.length) {
System.out.println("Board is full.");
} else {
rowToCopy.getChars(0, rowToCopy.length(), inputBoard[rowsFilledIn], 0);
++this.rowsFilledIn;
}
}

public String solve() {
// for (int i = 0; i < inputBoard.length; i++) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh. It's hard to resist implementing, isn't it? 😈

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// for (int j = 0; j < inputBoard[0].length; j++) {
//
// }
// }
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,41 @@
*/
public class MinesweeperTest {

@Ignore
@Test(expected = ZeroSizedBoardException.class)
public void zeroSizedBoardThrowException() {
public void zeroSizedBoardThrowException() throws ZeroSizedBoardException {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend using making ZeroSizedBoardException a RuntimeException so that you don't to declare it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea!

new Minesweeper(0, 0);
}

@Ignore
@Test(expected = ZeroSizedBoardException.class)
public void boardWithZeroRowsThrowsException() {
public void boardWithZeroRowsThrowsException() throws ZeroSizedBoardException {
new Minesweeper(0, 5);
}

@Ignore
@Test(expected = ZeroSizedBoardException.class)
public void boardWithZeroColumnsThrowsException() {
public void boardWithZeroColumnsThrowsException() throws ZeroSizedBoardException{
new Minesweeper(5, 0);
}

@Ignore
@Test(expected = RaggedBoardException.class)
public void raggedInputRowThrowsException() {
public void raggedInputRowThrowsException() throws ZeroSizedBoardException, RaggedBoardException{
Minesweeper board = new Minesweeper(1, 2);
board.addRow(".");
}

@Ignore
@Test(expected = RaggedBoardException.class)
public void raggedInputColumnThrowsException() {
public void raggedInputColumnThrowsException() throws ZeroSizedBoardException, RaggedBoardException{
Minesweeper board = new Minesweeper(2, 1);
board.addRow(".");
board.addRow("..");
}

@Ignore
@Test
public void oneSquareWithMine() {
public void oneSquareWithMine() throws ZeroSizedBoardException, RaggedBoardException{
Minesweeper board = new Minesweeper(1, 1);
board.addRow("*");

Expand All @@ -56,7 +55,7 @@ public void oneSquareWithMine() {

@Ignore
@Test
public void oneSquareWithNoMine() {
public void oneSquareWithNoMine() throws ZeroSizedBoardException, RaggedBoardException{
Minesweeper board = new Minesweeper(1, 1);
board.addRow(".");

Expand All @@ -66,7 +65,7 @@ public void oneSquareWithNoMine() {

@Ignore
@Test
public void twoByTwoBoardWithMineAtZeroZero() {
public void twoByTwoBoardWithMineAtZeroZero() throws ZeroSizedBoardException, RaggedBoardException {
Minesweeper board = new Minesweeper(2, 2);
board.addRow("*.");
board.addRow("..");
Expand Down