Created
February 17, 2012 10:03
-
-
Save bartenbach/1852373 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
/* | |
* To change this template, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package com.spades; | |
import java.util.Collections; | |
import java.util.LinkedList; | |
import java.util.List; | |
/** | |
* | |
* @author seed419 | |
*/ | |
public class GameManager { | |
private LinkedList<Team> teamList; | |
private LinkedList<Player> playerList; | |
/** | |
* Creates a new GameManager object and initializes a LinkedList of Teams | |
* and Players in the game. This class provides all the functionality for managing | |
* a game's score and players. | |
*/ | |
public GameManager() { | |
teamList = new LinkedList<Team>(); | |
playerList = new LinkedList<Player>(); | |
} | |
/** | |
* | |
* @return Returns a list of the teams in the game. | |
*/ | |
public List<Team> getTeams() { | |
return Collections.unmodifiableList(teamList); | |
} | |
/** | |
* | |
* @return Returns a list of the players in the game. | |
*/ | |
public List<Player> getPlayers() { | |
return Collections.unmodifiableList(playerList); | |
} | |
/** | |
* | |
* @param x Team to add to the list. | |
*/ | |
public void addTeam(Team x) { | |
teamList.add(x); | |
} | |
/** | |
* | |
* @param y Player to add to the list. | |
*/ | |
public void addPlayer(Player y) { | |
playerList.add(y); | |
} | |
/** | |
* | |
* @param team1 First team | |
* @param team2 Second team | |
* @param winningScore Score in which the game is over. | |
* @return Returns true if either team has exceeded the winning score. | |
*/ | |
public static boolean gameOver(Team team1, Team team2, int winningScore) { | |
if ((team1.getScore() < winningScore) && (team2.getScore() < winningScore)) { | |
return false; | |
} | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment