Class Game<T>
- Type Parameters:
T
- represents the moves that can be applied to the states
Conducts a two-player game whose moves are described by a single object.
-
Field Summary
Fields inherited from class game.console.AbstractGame
console, parser, state
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
makeMoveIfPossible
(T move) Applies the move specified to the state of the game if the move is a legal one.Methods inherited from class game.console.AbstractGame
printPrompt, printState, printStatus, readMove, start
-
Constructor Details
-
Game
Creates aGame
instance to conduct a two-player game whose moves are described by a single object on the console.- Parameters:
state
- the state from which the game is startedparser
- a function that converts a line read from the console to a move- Throws:
AssertionError
- if the console is not available
-
-
Method Details
-
makeMoveIfPossible
Description copied from class:AbstractGame
Applies the move specified to the state of the game if the move is a legal one. In case of a legal move, it should also print the updated state on the console with theAbstractGame.printState()
method.- Specified by:
makeMoveIfPossible
in classAbstractGame<State<T>,
T> - Parameters:
move
- the move to be made
-