Class PlayerVsRandomGame


  • public class PlayerVsRandomGame
    extends Game
    Class PlayerVsPlayerGame extend Game class and implement his two abstract methods for games Player versus Random(random generated moves).
    Author:
    Arterm Koliushko, https://www.linkedin.com/in/artem-koliushko/
    • 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 the Game.
        See Also:
        Constant Field Values
    • Constructor Detail

      • PlayerVsRandomGame

        public PlayerVsRandomGame()
        Constructor for class PlayerVsRandomGame.
        Initialize parent(Game class) constructor with a name of second player.
    • Method Detail

      • makeMove

        protected void makeMove()
        This method overrides parent Game.makeMove() method.
        This is recursive method, and it will be call its self till randomly generated value will be an empty cell. This method use Random 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.
        Specified by:
        makeMove in class Game