nmaguirre / minesweeper

A Simple MineSweeper Project
6 stars 4 forks source link

MinesweeperCell invalid method calls #100

Open nricci opened 8 years ago

nricci commented 8 years ago

Modify methods in MinesweeperCell so that they throw a corresponding exception when called in an invalid situation (e.g.: unblock() on a unblocked or opened cell).

LuuchoRocha commented 8 years ago

Solved in 1ea35ae

lbuttignol commented 8 years ago

Wrong implementation of method MinesweeperCell.unblock. The condition is too complex

The actual implementation is:

public void unblock() {
    if (!this.isBlocked() || this.isOpen())
        throw new IllegalStateException("Can't unblock an unblocked or opened cell");
   this.isBlockedCell = false;
}

I suggest this one:

public void unblock() {
    if (!this.isBlocked() )
        throw new IllegalStateException("Can't unblock an unblocked or opened cell");
    this.isBlockedCell = false;
}