Last active
October 20, 2017 07:37
-
-
Save darekmydlarz/54769e5dd6d8261f9193bc337db1b914 to your computer and use it in GitHub Desktop.
OOP Tic Tac Toe Draft - based on Elegant Objects by @yegor256
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Board { | |
Board movement(Movement movement); | |
Player winner(); | |
} | |
public static void main() { | |
Player black = new Player("Black"); | |
Player white = new Player("White"); | |
Board board = new Board(black, white); | |
Movement movement = new Movement(black, board).position(); | |
while(!board.hasWinner()) { | |
board = board.movement(new Movement(black, board)); | |
if(!board.hasWinner()) { | |
board = board.movement(new Movement(white, board)); | |
} | |
} | |
System.out.println("Congratulations! The winner is: " + board.winner()); | |
} |
Author
darekmydlarz
commented
Oct 20, 2017
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment