
import Board;

/** We suppose that a BoardDisplay class exists to display the
  * board and the pieces on it.
  *
  * @February 2000
  * @author Ming Gu, Yasir Mehboob, Mustally Hussain, Shiva Kabra,
  * Ammar Bandukwala.
  */
import BoardDisplay;

/**
 * A class Piece to store and change its information.
 *
 * @February 2000
 * @author Ming Gu
 */
public class Piece 
{
    // +--------+---------------------------------------------
    // | Fields |
    // +--------+

    /** The color of the piece. */
    protected String color;

    /** The row number of the piece. */
    protected int rownumber;

    /** The column number of the piece. */
    protected int columnnumber;

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

    /** The board this piece is on. */
    protected Board board;


    // +-------------+---------------------------------------
    // | Constructor |
    // +-------------+

    /**
     * Create a new piece with according position, color and
     * its board.
     */
    public Piece (int rown, int coln, String color,
                      Board boardname) {
        /**
         * Create a piece with the given parameters. Its flipnum
         * is set 0 at first. Its board is boardname.
         * Then call the method: board.putPiece(this) to put the
         * piece onto the board. Also call BoardDisplay  object
         * to graph the created piece.
         * Be sure that its position exists and is vacant on the
         * board.
         */
    } // Piece(int, int, String, Board)


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

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

    protected int getRow()
    {
        /** Get a piece's row number. */
    } // getRow()

    protected int getColumn()
    {
        /** Get a piece's column number. */
    } // getColumn()

    protected String getColor()
    {
        /** Get a piece's color. */
    } // getColor()

    protected int getFlip()
    {
        /** Get the piece's flip number.
          */
    } // getFlip()


    // +---------+--------------------------------------------
    // | Methods |
    // +---------+

    protected boolean moveOrnot()
    {
        /**
         * Return true about a certain ratio of the time.
         */
    } // moveOrnot()

    protected int countMovablePlace()
    {
        /**
         * Count the number of movable places. If there is not any
         * movable positions, return 0.
         */
    } // countMovablePlace()

    public void pieceMove (int newrownumber,
                           int newcolumnnumber)
    {
        /**
         * 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.
         */
    } // pieceMove(int, int)


    protected void realMove()
    {
        /**
         * Decide whether to move or not.  If yes, count the
         * number of movable places, than make a random move to
         * one of the places.
         */
    } // realMove()

    protected void flipAndmove()
    {
        /**
         * After flipping to a different color, delete the piece if
         * it is its nth time to flip. If not, make a real
         * move or remain at the same place or disappear.
         * This may make use of several methods defined previously
         * in this class.  Finally update the piece on the board and
         * on the graph.
         */
    } // flipAndmove()
} // class Piece

