-
Notifications
You must be signed in to change notification settings - Fork 13
Create the ultimate minesweeper #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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]; | ||
| } | ||
|
|
||
| } | ||
| 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++) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Heh. It's hard to resist implementing, isn't it? 😈
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
|---|---|---|
|
|
@@ -11,42 +11,41 @@ | |
| */ | ||
| public class MinesweeperTest { | ||
|
|
||
| @Ignore | ||
| @Test(expected = ZeroSizedBoardException.class) | ||
| public void zeroSizedBoardThrowException() { | ||
| public void zeroSizedBoardThrowException() throws ZeroSizedBoardException { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I recommend using making
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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("*"); | ||
|
|
||
|
|
@@ -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("."); | ||
|
|
||
|
|
@@ -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(".."); | ||
|
|
||


There was a problem hiding this comment.
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.