Class DefaultConnect4


  • public class DefaultConnect4
    extends Connect4
    Implementation for a default Connect4 game.
    • Constructor Detail

      • DefaultConnect4

        public DefaultConnect4​(java.lang.String firstPlayerName,
                               java.lang.String secondPlayerName)
        Constructor for a two player default Connect4 game.
        Parameters:
        firstPlayerName - Name of the first player
        secondPlayerName - Name of the second player
    • Method Detail

      • play

        public RoundResult play​(int x)
        Overrides the method to set a flag. Makes it possible to determine if it is okay to call play(int, int).
        Overrides:
        play in class Connect4
        Parameters:
        x - X coordinate which has to be between 1 and 7
        Returns:
        A RoundResult containing a message and a boolean telling if the round was valid
      • play

        public RoundResult play​(int x,
                                int y)
        Overrides the method to check for a flag. If the flag is not set, then this method was directly called which is not allowed for a default Connect4 game and a UnsupportedOperationException is thrown.
        Overrides:
        play in class Connect4
        Parameters:
        x - X coordinate which has to be between 1 and 7
        y - Y coordinate which has to be between 1 and 6
        Returns:
        A RoundResult containing a message and a boolean telling if the round was valid