Skip to content

For Review - #1

Open
jackgene wants to merge 1 commit into
prereviewfrom
review
Open

jackgene wants to merge 1 commit into
prereviewfrom
review

Conversation

@jackgene

@jackgene jackgene commented Jul 2, 2017

Copy link
Copy Markdown

This reverts commit ca74ea0.

private final JButton[][] buttons = new JButton[HEIGHT][WIDTH];
private final Random rng = new Random();
private Optional<boolean[][]> mines = Optional.empty();
private int numCellsRemaining;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is the number of cells that do not have a mine and has not yet been opened. The name is not clear and can be misunderstood to mean the number of cells not yet opened, including cells with bombs. It is not clear what this field is used for. All we know is that it is decremented (line 106).

* 2. The `numCellsRemaining` variable to the number of non-mine
* cells (`WIDTH` * `HEIGHT` - `NUM_MINES`).
*
* @param firstCellX X-index of first cell opened. This cannot be a mine.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I usually avoid x and y and use row and column (or row and col, or r and c). This avoids the confusion about whether rows corresponds to y or x.

// - Decrement `numCellsRemaining`
// - If all cells are open, display "You Win" in a dialog box
// - Extra credit: If the number of neighboring cells is 0,
// automatically open all neighboring cells

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is there any way to flag a bomb? Should it be extra credit?


final JPanel controlPanel = new JPanel();
final JButton resetButton = new JButton("Reset");
resetButton.addActionListener(null); // TODO replace null with method reference that resets the game

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The TODO is actually part of the assignment.

final MineSweeper mineSweeper = new MineSweeper();
SwingUtilities.invokeLater(mineSweeper::createAndShowFrame);
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Add tests so that the students can test their code as they progress. This gets them used to TDD and gives them a few carrots along the way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants