package tictactoe;

import exception.PlacementFailedException;
import game.AbstractGame;
import game.Coordinate;
import game.CustomScanner;

public class TicTacToe extends AbstractGame {
	private final static CustomScanner console = new CustomScanner();

	private final Team[] team;
	private int currentIndex;

	public TicTacToe() {
		super(new TicTacToeBoard());

		team = new Team[2];
		team[0] = new Team(Team.TeamType.X);
		team[1] = new Team(Team.TeamType.O);

		currentIndex = 0;

	}

	// There should only be a PlacementFailedException
	@Override
	public void next() {
		Coordinate input;

		try {
			input = console.getSquareCoordinates(this);
			System.out.println();

			getBoard().attemptPlace(team[currentIndex].getPieceType(), input);

			printBoard();
			currentIndex = currentIndex == 0 ? 1 : 0;

		} catch (PlacementFailedException e) {
			errorMessage(e.toString());
		} catch (ArrayIndexOutOfBoundsException e) {
			errorMessage(e.toString());
		} catch (NullPointerException e) {
			errorMessage("InputFailed");
		}

	}

	@Override
	public void check() {
		char team = getBoard().gameEnd();

		if (team != ' ') {
			if (team == '_') {
				System.out.println("It's a tie!");
			} else {
				System.out.println(team + " won!");
			}

			endGame();
		}
	}
}
@@ -15,16 +15,57 @@
 toe;%0D%0A%0D%0A
+import exception.InputInvalidException;%0D%0A
 import e
@@ -973,29 +973,20 @@
 ch (
-ArrayIndexOutOfBounds
+InputInvalid
 Exce
@@ -1036,79 +1036,8 @@
 %0A%09%09%7D
- catch (NullPointerException e) %7B%0D%0A%09%09%09errorMessage(%22InputFailed%22);%0D%0A%09%09%7D
 %0D%0A%0D%0A

add catch for InputInvalidException in TicTacToe#next()