Created
January 28, 2009 09:42
-
-
Save slawosz/53881 to your computer and use it in GitHub Desktop.
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
public class Game { | |
Gameboard gameboard; | |
ComputerPlayer player2; | |
HumanPlayer player1; | |
ComputerPlayer player4; | |
HumanPlayer player3; | |
public Game(Gameboard gameboard, | |
HumanPlayer player1, | |
ComputerPlayer player2) | |
{ | |
this.gameboard = gameboard; | |
this.player1 = player1; | |
this.player2 = player2; | |
} | |
public Game(Gameboard gameboard, | |
HumanPlayer player1, | |
HumanPlayer player2) | |
{ | |
this.gameboard = gameboard; | |
this.player1 = player1; | |
this.player3 = player2; | |
} | |
public Game(Gameboard gameboard, | |
ComputerPlayer player1, | |
HumanPlayer player2) | |
{ | |
this.gameboard = gameboard; | |
this.player2 = player1; | |
this.player1 = player2; | |
} | |
public Game(Gameboard gameboard, | |
ComputerPlayer player1, | |
ComputerPlayer player2) | |
{ | |
this.gameboard = gameboard; | |
this.player4= player1; | |
this.player2 = player2; | |
} | |
public int play() { | |
char winner; | |
while (true) { | |
player1.move(gameboard); | |
if (gameboard.gameOver()) | |
{ | |
winner = player1.getChar(); | |
break; | |
} | |
player2.move(gameboard); | |
if (gameboard.gameOver()) | |
{ | |
winner = player2.getChar(); | |
break; | |
} | |
} | |
return gameboard.winner(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment