HELP PLEASE Modify the code so that there are twelve RED pie

HELP PLEASE

Modify the code so that there are twelve RED pieces, positioned on the black squares of the bottom three rows of the board.

Create a BlackGamePiece class, and add BLACK pieces to their appropriate starting positions (i.e. on the 12 black squares in the top 3 rows of the board).

Ensure that BLACK pieces move appropriately.

Solution

import java.awt.BasicStroke;

import java.awt.Color;

import java.awt.Graphics2D;

import java.awt.geom.Ellipse2D;

public class RedGamePiece extends GamePiece

{

public RedGamePiece (int row, int col) {

super (row, col, Player.RED);

}

public RedGamePiece (Position pos) {

this (pos.r, pos.c);

}

protected boolean validNonJump (int dr, int dc, GameSquares squares)

{

if ((dr == -1) && ( (dc == -1) || (dc == 1) ))

{

if (squares.getSquare(pos.r + dr, pos.c + dc).getPiece() == null)

return true;

}

return false;

}

protected boolean validJump (int dr, int dc, GameSquares squares)

{

return false;

}

public void drawPiece (Graphics2D g2, int x, int y, int width, int height)
{

Ellipse2D.Double outline = new Ellipse2D.Double (x + width * DIST_FROM_EDGE + LINE_WIDTH / 2,

y + height * DIST_FROM_EDGE + LINE_WIDTH / 2,

width * (1 - 2 * DIST_FROM_EDGE) - LINE_WIDTH,

height * (1 - 2 * DIST_FROM_EDGE) - LINE_WIDTH);

g2.setColor (Color.RED);

BasicStroke stroke = new BasicStroke (LINE_WIDTH);

g2.setStroke(stroke);

g2.fill (outline);

if (selected)

{

g2.setColor (Color.GREEN);

g2.draw (outline);

}

}

}

HELP PLEASE Modify the code so that there are twelve RED pieces, positioned on the black squares of the bottom three rows of the board. Create a BlackGamePiece
HELP PLEASE Modify the code so that there are twelve RED pieces, positioned on the black squares of the bottom three rows of the board. Create a BlackGamePiece

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site