Skip to content

Instantly share code, notes, and snippets.

@slawosz
Created January 28, 2009 09:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slawosz/53881 to your computer and use it in GitHub Desktop.
Save slawosz/53881 to your computer and use it in GitHub Desktop.
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