Package com.neven.ticTacToeGame.model
Class PlayerVsRandomGame
- java.lang.Object
-
- com.neven.ticTacToeGame.model.Game
-
- com.neven.ticTacToeGame.model.PlayerVsRandomGame
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
PLAYER_2_NAME
Constant with a name of the player2(in this case "Random").
-
Constructor Summary
Constructors Constructor Description PlayerVsRandomGame()
Constructor for classPlayerVsRandomGame
.
Initialize parent(Game
class) constructor with a name of second player.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Game
makeFirstMove()
This method overrides parentGame.makeFirstMove()
method.protected void
makeMove()
This method overrides parentGame.makeMove()
method.-
Methods inherited from class com.neven.ticTacToeGame.model.Game
isPlayerWin, switchCurrentPlayer, winningCheckAndMakingMove
-
-
-
-
Field Detail
-
PLAYER_2_NAME
private static final java.lang.String PLAYER_2_NAME
Constant with a name of the player2(in this case "Random"). Used in constructor for creation an object of theGame
.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PlayerVsRandomGame
public PlayerVsRandomGame()
Constructor for classPlayerVsRandomGame
.
Initialize parent(Game
class) constructor with a name of second player.
-
-
Method Detail
-
makeFirstMove
public Game makeFirstMove()
This method overrides parentGame.makeFirstMove()
method.
Method just callmakeMove()
method and return current game.- Specified by:
makeFirstMove
in classGame
- Returns:
Game
with randomly generated "Random" move.
-
makeMove
protected void makeMove()
This method overrides parentGame.makeMove()
method.
This is recursive method, and it will be call its self till randomly generated value will be an empty cell. This method useRandom
for generating random value within 1-9(amount of game field cells). Generated value will be a number of game field cell to which put "Random" name value. this cell wil be a "Random" move in the game.
-
-