view.cl
Class CommandLineUI

java.lang.Object
  extended by view.cl.CommandLineUI
All Implemented Interfaces:
UserInterface

public class CommandLineUI
extends java.lang.Object
implements UserInterface

Provides command line portrait of the game.


Constructor Summary
CommandLineUI()
          constructor: Constructs a new CommandLineUI game.
 
Method Summary
 boolean isOverDraw(boolean color)
          accessor(observer): Checks whether we are at a draw state when the Player with the given color has turn to play and informs by returning a boolean value the end or the continuity of the match.
 boolean isOverWin(boolean color)
          accessor(observer): Checks whether we are at a check mate(the player with the pieces of the given color) state and informs by returning a boolean value that indicates the end or the continuity of the match.
 boolean makeMove(Cell a, Cell b)
          transformer(mutative): Executes the move which is provided by the parameter integers which defines two cells, a source and a destination one.
 boolean makeMove(java.lang.String command)
          transformer(mutative): Executes the move which is provided by the parameter string in the form of "a2 => a3".
 void nextGame()
          transformer(mutative): Changes the chess board of the game to show to a next board.
 void previousGame()
          transformer(mutative): Changes the chess board of the game to show to a previous move.
 void showGame()
          accessor(selector): Prints the chess board of a game.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandLineUI

public CommandLineUI()
constructor: Constructs a new CommandLineUI game.
postcondition: Creates a new Game, thus starting the game.

Method Detail

makeMove

public boolean makeMove(java.lang.String command)
transformer(mutative): Executes the move which is provided by the parameter string in the form of "a2 => a3".
postcondition: Runs the move which is defined by the parameter String.

Parameters:
command - String defines the move to be played.
Returns:
true if move was legal and executed, else false.

makeMove

public boolean makeMove(Cell a,
                        Cell b)
transformer(mutative): Executes the move which is provided by the parameter integers which defines two cells, a source and a destination one.
postconditions: Runs the move which is defined by the parameter integers. Returns true if move is successfully executed, false otherwise.

Specified by:
makeMove in interface UserInterface
Parameters:
a - source Cell
b - destination Cell
Returns:
true if move is executed, false otherwise.
Throws:
java.lang.InterruptedException

nextGame

public void nextGame()
              throws IllegalViewException
transformer(mutative): Changes the chess board of the game to show to a next board.
preconditions: Before invoking this method, previousGame() has been invoked and has changed the chess board.
postconditions: The game now shows to one state after where the prevGame() has taken us.

Specified by:
nextGame in interface UserInterface
Throws:
IllegalViewException - When there is no next board to go.

previousGame

public void previousGame()
                  throws IllegalViewException
transformer(mutative): Changes the chess board of the game to show to a previous move.
preconditions: Before invoking this method, there is at least one move done in the board. postconditions: If current game is at the beginning , the board will be changed, showing the previous state of it.

Specified by:
previousGame in interface UserInterface
Throws:
IllegalViewException - When there is no previous board to go.

showGame

public void showGame()
accessor(selector): Prints the chess board of a game.
postcondition:Prints the board of the game.

Specified by:
showGame in interface UserInterface

isOverDraw

public boolean isOverDraw(boolean color)
accessor(observer): Checks whether we are at a draw state when the Player with the given color has turn to play and informs by returning a boolean value the end or the continuity of the match. Is called upon after every turn.
postcondition: Checks after every move the state of the game, if it fulfills.

Returns:
true if is draw, else false

isOverWin

public boolean isOverWin(boolean color)
accessor(observer): Checks whether we are at a check mate(the player with the pieces of the given color) state and informs by returning a boolean value that indicates the end or the continuity of the match. Is called upon after every turn.
postcondition: Checks after every move the state of the king and returns the appropriate boolean value(true if terminally checked)

Returns:
a boolean value concerning the state of the game