예제 #1
0
 /**
  * Method to move the figure to new position
  *
  * @param p position where the figure should be after the move
  * @return if there is a figure in position p, it is thrown out and returned by this method,
  *     otherwise returns null
  */
 public Figure move(Position p) {
   if (canMove(p) == true) {
     Figure thrownFig = this.killFigure(p);
     // System.out.println(thrownFig.getPosition().getColumn() + " " +
     // thrownFig.getPosition().getRow());
     this.pos.removeFigure();
     p.putFigure(this);
     this.pos = p;
     return thrownFig;
   }
   return null;
 }
예제 #2
0
 /**
  * Constructor of the Figure object
  *
  * @param p position where the new figure will lie on
  * @param color color of the new figure - black = 0, white = 1
  */
 public Figure(Position p, int color) {
   p.putFigure(this);
   this.pos = p;
   this.color = color;
 }