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
16 changes: 13 additions & 3 deletions minesweeper/src/main/java/edu/pdx/cs410J/katas/Minesweeper.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,22 @@

public class Minesweeper {

public Minesweeper(int row, int column) {
private int row;
private int column;
private int currentRow;

public Minesweeper(int row, int column) throws ZeroSizedBoardException {
if((row == 0) || (column == 0)) {
throw new ZeroSizedBoardException();
}
currentRow = 1;
}

public void addRow(String row) {

public void addRow(String inputRow) {
if(inputRow.length() != column || (currentRow > row)){
throw new RaggedBoardException();
}
currentRow++;
}

public String solve() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package edu.pdx.cs410J.katas;

public class RaggedBoardException extends Throwable {
public class RaggedBoardException extends RuntimeException {
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package edu.pdx.cs410J.katas;

public class ZeroSizedBoardException extends Throwable {
public class ZeroSizedBoardException extends RuntimeException {
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,27 @@
*/
public class MinesweeperTest {

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

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

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

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

@Ignore
@Test(expected = RaggedBoardException.class)
public void raggedInputColumnThrowsException() {
Minesweeper board = new Minesweeper(2, 1);
Expand Down