Package tk.dmanstrator.connectfour
Class DefaultConnect4
- java.lang.Object
-
- tk.dmanstrator.connectfour.Connect4
-
- tk.dmanstrator.connectfour.DefaultConnect4
-
public class DefaultConnect4 extends Connect4
Implementation for a default Connect4 game.
-
-
Constructor Summary
Constructors Constructor Description DefaultConnect4(java.lang.String firstPlayerName, java.lang.String secondPlayerName)
Constructor for a two player default Connect4 game.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RoundResult
play(int x)
Overrides the method to set a flag.RoundResult
play(int x, int y)
Overrides the method to check for a flag.-
Methods inherited from class tk.dmanstrator.connectfour.Connect4
getCurrentField, getCurrentField, getCurrentPlayerName, getFirstPlayerName, getGameLog, getPlayedRounds, getSecondPlayerName, isDraw, isGameOver, toString
-
-
-
-
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 callplay(int, int)
.- Overrides:
play
in classConnect4
- 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 aUnsupportedOperationException
is thrown.- Overrides:
play
in classConnect4
- Parameters:
x
- X coordinate which has to be between 1 and 7y
- 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
-
-