import Board;
import Position;


/**
 * A class Piece to store and change its information.
 *
 * @March 2000
 * @author Ming Gu, Yasir Mehboob, Ammar Bandukwala, Mustally Hussain, 
 * Shiva Kabra.
 */
public class Piece 
{
    // +--------+---------------------------------------------
    // | Fields |
    // +--------+

    /** The color of the piece. */
    public int color;
    
    /** The position of the piece. */ 
    public Position position; 

    /** The number of times the piece has been flipped. */ 
    public int flipnumber; 

    /** The board this piece is on. */ 
    public Board board;
   
    // +--------------+-----------------------------------------
    // | Constructors |
    // +--------------+
    /** 
     * Create a piece with its position, color and Board as its
     * parameters.  
     */
    public Piece(int row, int column, int col, Board b) {
        this.position = new Position(row, column);
        this.color = col;
        this.board = b;
        this.flipnumber = 0;
    }

    // +------------+-----------------------------------------
    // | Extractors |
    // +------------+

    /** 
     * Some other objects may ask a piece for its information,
     * so some necessary extractors are needed.
     */

    /** Get a piece's row number. */
    public int getRow() {
        return position.getRow();
    }
   
    /** Get a piece's column number. */
    public int getColumn() {
        return position.getColumn();
    }
    
    /** Get a piece's color. */
    public int getColor() {
        return color;
    }
    
    /** Get the piece's flip number. */
    public int getFlip() {
        return flipnumber;
    }

    
    // +---------+--------------------------------------------
    // | Methods |
    // +---------+
    
    /**
     * Move a piece, with nothing changed but its position.
     * Update the piece's own position field.
     * Call board.movePiece(this.rownumber, 
     *                      this.columnnumber,
     *                      newrownumber,
     *                      newcolumnnumber)
     * to update its index on board.
     */
    public void pieceMove(int newrow, int newcol) {
        position = new Position(newrow, newcol);
    }

    /** 
     * Flip to a different color and update its flipnumber 
     * by adding 1.
     */
    public void flip() {
        color = color + 1;
        flipnumber++;
            }
} // class Piece

       

