import java.awt.Color; public class Piece { private Color color; private int row; private int col; public Piece(){ setColor(Color.RED); setRow(-1); setCol(-1); } public Piece(Color color, int r, int c){ this(); setColor(color); setRow(r); setCol(c); } /** * @param color the color to set */ public void setColor(Color color) { this.color = color; } /** * @return the color */ public Color getColor() { return color; } /** * @param row the row to set */ public void setRow(int row) { this.row = row; } /** * @return the row */ public int getRow() { return row; } /** * @param col the col to set */ public void setCol(int col) { this.col = col; } /** * @return the col */ public int getCol() { return col; } public void setLocation(int r, int c){ setRow(r); setCol(c); } public String toString(){ String theColor="Black"; if (color.equals(Color.RED)) theColor=" Red "; return "Piece[row = "+row+" col = "+col+" ("+theColor+")]"; } public boolean equals(Piece p){ return p.getColor().equals(color); } }