package lect78_impl.model; /** * @overview Represents a single cell on the game board * * @attributes * position Position Position on the board * tank Tank Tank on this cell (or null) */ public class Cell { private Position position; private Tank tank; /** * @effects Initializes this as an empty Cell at given position */ public Cell(Position position) { this.position = position; this.tank = null; } /** * @effects Returns the position of this cell */ public Position getPosition() { return position; } /** * @effects Returns the tank on this cell, or null if empty */ public Tank getTank() { return tank; } /** * @effects Places a tank on this cell */ public void setTank(Tank tank) { this.tank = tank; } /** * @effects Checks if this cell is empty (has no tank) */ public boolean isEmpty() { return tank == null; } /** * @effects Returns string representation of this cell */ @Override public String toString() { return "Cell at " + position + (isEmpty() ? " (empty)" : " (has tank)"); } }