pawnish
A particular "piece" for a game played on an 8x8 board can move 1-2 forward or backward (up-and-down) as long as there is nothing in the way. This piece cannot jump over any pieces in its way. For example, if there is something directly below it, it cannot jump it to go to the 2nd empty tile from its location regardless of whether or not it is open.
The Piece class is used to describe a Piece
object. It is defined by its row and column (col) location. The class is shown below.
public class Piece{Complete the method
private int row, col;
public Piece(int r, int c){ /* implementation not shown */ }
//accessors (getters)
private int getRow(){ /* implementation not shown */ }private int getCol(){ /* implementation not shown */ }
}
moves
which takes in a Piece
object and a 2D boolean array describing which tiles are free (no piece on it).The method should return a 2D array of
booleans
where the possible moves for the Piece
object are set to true
.
For example, if the Piece is at location 2,2 then the following is the returned boolean array
Type your solution
Skills Practiced:
3.C
3.E
4.A
4.B
Saved
Saved