diff --git a/minesweeper/src/main/java/edu/pdx/cs410J/katas/Minesweeper.java b/minesweeper/src/main/java/edu/pdx/cs410J/katas/Minesweeper.java index 3fe6bf0..dbaa5fe 100644 --- a/minesweeper/src/main/java/edu/pdx/cs410J/katas/Minesweeper.java +++ b/minesweeper/src/main/java/edu/pdx/cs410J/katas/Minesweeper.java @@ -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() { diff --git a/minesweeper/src/main/java/edu/pdx/cs410J/katas/RaggedBoardException.java b/minesweeper/src/main/java/edu/pdx/cs410J/katas/RaggedBoardException.java index 955cf7b..4cbfc89 100644 --- a/minesweeper/src/main/java/edu/pdx/cs410J/katas/RaggedBoardException.java +++ b/minesweeper/src/main/java/edu/pdx/cs410J/katas/RaggedBoardException.java @@ -1,4 +1,4 @@ package edu.pdx.cs410J.katas; -public class RaggedBoardException extends Throwable { +public class RaggedBoardException extends RuntimeException { } diff --git a/minesweeper/src/main/java/edu/pdx/cs410J/katas/ZeroSizedBoardException.java b/minesweeper/src/main/java/edu/pdx/cs410J/katas/ZeroSizedBoardException.java index 714ed09..52636ff 100644 --- a/minesweeper/src/main/java/edu/pdx/cs410J/katas/ZeroSizedBoardException.java +++ b/minesweeper/src/main/java/edu/pdx/cs410J/katas/ZeroSizedBoardException.java @@ -1,4 +1,4 @@ package edu.pdx.cs410J.katas; -public class ZeroSizedBoardException extends Throwable { +public class ZeroSizedBoardException extends RuntimeException { } diff --git a/minesweeper/src/test/java/edu/pdx/cs410J/katas/MinesweeperTest.java b/minesweeper/src/test/java/edu/pdx/cs410J/katas/MinesweeperTest.java index c209511..560b51a 100644 --- a/minesweeper/src/test/java/edu/pdx/cs410J/katas/MinesweeperTest.java +++ b/minesweeper/src/test/java/edu/pdx/cs410J/katas/MinesweeperTest.java @@ -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);