package game;

import static com.google.common.base.Preconditions.checkArgument;

import java.util.Optional;

/**
 * Created by Dimitry on 14.05.2016.
 */
public class Board
{
  private Player startingPlayer;
  private final int numberOfRows;
  private final int numberOfColumns;
  private Player[][] occupiers;

  public Board(final int numberOfRows, final int numberOfColumns) {
    this.numberOfRows = numberOfRows;
    this.numberOfColumns = numberOfColumns;
    occupiers = new Player[numberOfRows][numberOfColumns];
  }

  public Optional<Player> slotOwner(final int row, final int column) {
    if (occupiers[row][column] == null) {
      return Optional.empty();
    } else {
      return Optional.of(occupiers[row][column]);
    }
  }

  public void insertChip(final int columnNumber, final Player player) {
    int index = numberOfRows - 1;
    while (index >= 0 && occupiers[index][columnNumber] != null) {
      index--;
    }
    checkArgument(index >= 0);
    occupiers[index][columnNumber] = player;
  }

  public int getNumberOfRows() {
    return numberOfRows;
  }

  public int getNumberOfColumns() {
    return numberOfColumns;
  }

  public void setStartingPlayer(final Player player) {
    this.startingPlayer = player;
  }

  public Player getStartingPlayer() {
    return startingPlayer;
  }
}

@@ -173,41 +173,8 @@
 d%0A%7B%0A
-  private Player startingPlayer;%0A
   pr
@@ -1114,171 +1114,7 @@
 %0A  %7D
-%0A%0A  public void setStartingPlayer(final Player player) %7B%0A    this.startingPlayer = player;%0A  %7D%0A%0A  public Player getStartingPlayer() %7B%0A    return startingPlayer;%0A  %7D
 %0A%7D%0A

Revoke starting player from the board.