Package popinjay
Class Board
- java.lang.Object
-
- popinjay.Board
-
public class Board extends java.lang.Object
A mutable state of the puzzle board, with some set of pieces placed on it.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addPiece(Piece p)
Effect: Add a piece to the board and return true.boolean
classInv()
Invariant: All pieces fit fully on valid board points and do not overlap.boolean
open(int x, int y)
Whether this is an unoccupied, valid board point.void
removePiece(Piece p)
Effect: Remove a piece from the board.int
sizeX()
The horizontal size of the board.int
sizeY()
The vertical size of the board.java.lang.String
toString()
boolean
valid(int x, int y)
Whether this is a valid board point.
-
-
-
Method Detail
-
valid
public boolean valid(int x, int y)
Whether this is a valid board point.
-
open
public boolean open(int x, int y)
Whether this is an unoccupied, valid board point.
-
classInv
public boolean classInv()
Invariant: All pieces fit fully on valid board points and do not overlap. Further, a point on the board is occupied by a piece if and only if that pieces is in the set of pieces, and it's a point that belongs to the piece.
-
addPiece
public boolean addPiece(Piece p)
Effect: Add a piece to the board and return true. Return false if the piece can't be placed.
-
removePiece
public void removePiece(Piece p)
Effect: Remove a piece from the board.
-
sizeX
public int sizeX()
The horizontal size of the board.
-
sizeY
public int sizeY()
The vertical size of the board.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-