package game;

import game.CustomScanner;

/**
 * This class contains the board of the game and the game loop method.
 *
 */
public abstract class AbstractGame {
	/**
	 * console is a CustomScanner that is accessed by every game object that
	 * extends AbstractGame
	 */
	private final static CustomScanner console = new CustomScanner();
	/** this is keeps track of where the pieces in the game are placed */
	private final Board board;
	/** this is a boolean value that determines if the game continues or ends */
	private boolean play;

	/**
	 * The constructor for any game, only visible to its subclasses.
	 * 
	 * @param board
	 *            the board the game will be played on
	 */
	protected AbstractGame(Board board) {
		this.board = board;
		play = true;

		printBoard();
	}

	/**
	 * This method repeats another turn in the game until the condition to end
	 * the game is satisfied.
	 */
	public void startGame() {
		while (play) {
			next();
			check();
		}
	}

	/**
	 * This method ends the game loop, ending the game.
	 */
	public void endGame() {
		play = false;
	}

	/**
	 * This method represents a single turn of one of the players in the game.
	 */
	public abstract void next();

	/**
	 * This method checks if the game has ended and the program should close.
	 */
	public abstract void check();

	/**
	 * This method prints a text representation of the board to the system.
	 */
	public void printBoard() {
		System.out.println(board);
	}

	/**
	 * This method is for debugging purposes and eventually telling the user
	 * what they did incorrectly.
	 * 
	 * @param error
	 *            the exception name or a custom message
	 */
	public void errorMessage(String error) {
		System.out.println("Invalid: " + error);
	}

	/**
	 * This method returns the board.
	 * 
	 * @return the board the game is being played on
	 */
	public Board getBoard() {
		return board;
	}

	/**
	 * This method returns the custom input interpreter, CustomScanner, for all
	 * games.
	 * 
	 * @return the custom scanner for games
	 */
	public static CustomScanner getConsole() {
		return console;
	}
}
@@ -235,46 +235,93 @@
 game
- object that%0D%0A%09 * extends AbstractGame
+. It interprets%0D%0A%09 * the user's input into an output that the program can understand.
 %0D%0A%09 
@@ -397,23 +397,21 @@
 ;%0D%0A%09/** 
-this is
+board
  keeps t
@@ -496,20 +496,20 @@
 ;%0D%0A%09/** 
-this
+play
  is a bo
@@ -631,10 +631,8 @@
 or a
-ny
  gam
@@ -1057,123 +1057,8 @@
 %0D%0A%0D%0A
-%09/**%0D%0A%09 * This method ends the game loop, ending the game.%0D%0A%09 */%0D%0A%09public void endGame() %7B%0D%0A%09%09play = false;%0D%0A%09%7D%0D%0A%0D%0A
 %09/**
@@ -1220,46 +1220,18 @@
 ame 
-has ended and the program 
 should 
-close
+end
 .%0D%0A%09
@@ -1262,24 +1262,118 @@
 id check();%0D
+%0A%09%0D%0A%09/**%0D%0A%09 * This method ends the game.%0D%0A%09 */%0D%0A%09public void endGame() %7B%0D%0A%09%09play = false;%0D%0A%09%7D%0D
 %0A%0D%0A%09/**%0D%0A%09 *
@@ -1440,16 +1440,27 @@
 e system
+ out stream
 .%0D%0A%09 */%0D
@@ -1531,116 +1531,102 @@
 %0D%0A%09/
-**%0D%0A%09 * This method is for debugging purposes and eventually telling the user%0D%0A%09 * what they did incorrectly
+/ TODO make it an error message to the player%0D%0A%09/**%0D%0A%09 * This method is for debugging purposes
 .%0D%0A%09
@@ -2035,28 +2035,8 @@
 nner
-, for all%0D%0A%09 * games
 .%0D%0A%09

update comments