package org.copinf.cc.model;

/**
 * Provides internal representation of a square on a board.
 */
public class Square {

	private Pawn pawn;
	private final Coordinates coordinates;

	/**
	 * Constructs a new empty Square at specified coordinates.
	 * @param coordinates this square location
	 */
	public Square(final Coordinates coordinates) {
		this(null, coordinates);
	}

	/**
	 * Constructs a new Square with a pawn at specified coordinates.
	 * @param pawn a pawn
	 * @param coordinates this square location
	 */
	public Square(final Pawn pawn, final Coordinates coordinates) {
		this.pawn = pawn;
		this.coordinates = coordinates;
	}

	/**
	 * Gets the pawn in this square.
	 * @return the pawn
	 */
	public Pawn getPawn() {
		return pawn;
	}

	/**
	 * Sets a pawn in this square.
	 * @param pawn a pawn
	 */
	public void setPawn(final Pawn pawn) {
		this.pawn = pawn;
	}

	/**
	 * Checks if this square is free (there's no pawn on it).
	 * @return true if this square is free
	 */
	public boolean isFree() {
		return pawn == null;
	}

	/**
	 * Gets this square coordinates.
	 * @return this square coordinates
	 */
	public Coordinates getCoordinates() {
		return this.coordinates;
	}
}

@@ -138,207 +138,69 @@
 wn;%0A
-%09private final Coordinates coordinates;%0A%0A%09/**%0A%09 * Constructs a new empty Square at specified coordinates.%0A%09 * @param coordinates this square location%0A%09 */%0A%09public Square(final Coordinates coordinates
+%0A%09/**%0A%09 * Constructs a new empty Square.%0A%09 */%0A%09public Square(
 ) %7B%0A
@@ -214,21 +214,8 @@
 null
-, coordinates
 );%0A%09
@@ -265,33 +265,8 @@
 pawn
- at specified coordinates
 .%0A%09 
@@ -293,171 +293,62 @@
 %0A%09 *
- @param coordinates this square location%0A%09 */%0A%09public Square(final Pawn pawn, final Coordinates coordinates) %7B%0A%09%09this.pawn = pawn;%0A%09%09this.coordinates = coordinates
+/%0A%09public Square(final Pawn pawn) %7B%0A%09%09this.pawn = pawn
 ;%0A%09%7D
@@ -600,17 +600,24 @@
 %09 * 
-Checks if
+Pops the pawn in
  thi
@@ -628,61 +628,50 @@
 uare
- is free (there's no pawn on it).%0A%09 * @return true if
+.%0A%09 * @return the pawn that was located in
  thi
@@ -683,69 +683,110 @@
 are 
-is free%0A%09 */%0A%09public boolean isFree() %7B%0A%09%09return pawn == null
+or null if it was empty%0A%09 */%0A%09public Pawn popPawn() %7B%0A%09%09Pawn prev = pawn;%0A%09%09pawn = null;%0A%09%09return prev
 ;%0A%09%7D
@@ -796,20 +796,25 @@
 /**%0A%09 * 
-Gets
+Checks if
  this sq
@@ -818,27 +818,47 @@
  square 
-coordinates
+is free (there's no pawn on it)
 .%0A%09 * @r
@@ -859,24 +859,32 @@
 %09 * @return 
+true if 
 this square 
@@ -883,27 +883,23 @@
  square 
-coordinates
+is free
 %0A%09 */%0A%09p
@@ -908,64 +908,48 @@
 lic 
-Coordinates getCoordinates() %7B%0A%09%09return this.coordinates
+boolean isFree() %7B%0A%09%09return pawn == null
 ;%0A%09%7D

Remove link to Coordinates in Square