public class UDPiece extends Piece
Constructor and Description |
---|
UDPiece(char[][] board,
char displayChar,
int size,
int topRow,
int leftCol)
Call the superclass (Piece) constructor with the same parameters.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canMoveDir(Direction d)
Return whether or not the piece is, in general, permitted to move in the given direction.
|
int |
getBottomRow()
Return the row of the piece's bottom right corner.
|
int |
getRightCol()
Return the column of the piece's bottom right corner.
|
getLeftCol, getTopRow, toString, tryMove
public UDPiece(char[][] board, char displayChar, int size, int topRow, int leftCol)
board
- a reference to the RandomRailroadRushHour char[][] board object common to all piecesdisplayChar
- the character used to "paint" the piece on the board representationsize
- the size of the piece. For up/down- or left/right-moving train pieces (with width 1), this is the piece length in grid squares.
For left/right/up/down-moving platform pieces, this is the size length in grid squares.topRow
- the row of the piece's top left cornerleftCol
- the column of the piece's top left cornerpublic int getBottomRow()
Piece
getBottomRow
in class Piece
public int getRightCol()
Piece
getRightCol
in class Piece
public boolean canMoveDir(Direction d)
Piece
canMoveDir
in class Piece
d
- given direction of movement