Пример #1
0
 /**
  * Create a new League object, given the set of initial attribute values.
  * @param name the name of the league
  * @param leagueRules the rules of participating in the league
  * @param matchRules the match rules for matches played in the league
  * @param isIndoor is the league an indoor league?
  * @param minTeams the minimum number of teams in the league
  * @param maxTeams the maximum number of teams in the league
  * @param minPlayers the minimum number of players in teams in the league
  * @param maxPlayers the maximum number of players in teams in the league
  * @return a new League instance with the given attribute values
  * @throws RDException in case either the name is null or any of the team/player numbers is not positive or the given maximum is less than the corresponding minimum
  */
 public function createLeague($name = null, $leagueRules = null, $matchRules = null, $isIndoor = null, $minTeams = null, $maxTeams = null, $minPlayers = null, $maxPlayers = null)
 {
     $aLeague = new Entity\LeagueImpl();
     // if ($name != null && $leagueRules != null && $matchRules && $isIndoor != null &&
     //   $minTeams != null && $maxTeams != null && $minPlayers != null && $maxPlayers != null) {
     $aLeague->setName($name);
     $aLeague->setLeagueRules($leagueRules);
     $aLeague->setMatchRules($matchRules);
     $aLeague->setIsIndoor($isIndoor);
     $aLeague->setMinTeams($minTeams);
     $aLeague->setMaxTeams($maxTeams);
     $aLeague->setMinMembers($minPlayers);
     $aLeague->setMaxMembers($maxPlayers);
     // }
     return $aLeague;
 }
Пример #2
0
 /**
  * Team is set as league winner
  *
  * @param Entity\LeagueImpl $league
  * @param Entity\TeamImpl $team
  * @throws RDException is thrown if team is not in the league.
  * @return void
  */
 public function selectLeagueWinner($league, $team)
 {
     if ($team->getParticipatesInLeague()->getName() != $league->getName()) {
         throw new RDException($string = "Team is not in this league.");
     }
     $this->objectLayer->createTeamWinnerOfLeague($team, $league);
 }
Пример #3
0
 /**
  * Deletes winner.
  *
  * @param Entity\TeamImpl $team
  * @param Entity\LeagueImpl $league
  * @throws RDException
  */
 public function deleteWinner($team, $league)
 {
     $q = 'DELETE FROM is_winner_of WHERE team_id = ? AND league_id = ?;';
     //create Prepared statement
     $stmt = $this->dbConnection->prepare($q);
     //bind parameter to query
     $teamId = $team->getId();
     $leagueId = $league->getId();
     $stmt->bindParam(1, $teamId, \PDO::PARAM_INT);
     $stmt->bindParam(2, $leagueId, \PDO::PARAM_INT);
     //execute query
     if ($stmt->execute()) {
         echo 'link deleted successfully';
     } else {
         throw new RDException('Deletion of link unsuccessful');
     }
 }
Пример #4
0
 /**
  * @param \edu\uga\cs\recdawgs\entity\impl\LeagueImpl $league
  * @param int $leagueId
  */
 public function listInfo($league = null, $leagueId = -1)
 {
     $html = "";
     if ($league) {
         $leagueRules = $league->getLeagueRules();
         $matchRules = $league->getMatchRules();
         $minTeams = $league->getMinTeams();
         $maxTeams = $league->getMaxTeams();
         $minPlayers = $league->getMinMembers();
         $maxPlayers = $league->getMaxMembers();
         $location = $league->getIsIndoor() ? "Indoor" : "Outdoor";
         $winner = $league->getWinnerOfLeague() != null ? $league->getWinnerOfLeague()->getName() : "None";
         $html .= "<ul>";
         $html .= "<li>League rules: {$leagueRules}</li>";
         $html .= "<li>Match rules {$matchRules}</li>";
         $html .= "<li>Min Teams: {$minTeams}</li>";
         $html .= "<li>Max Teams: {$maxTeams}</li>";
         $html .= "<li>Min Players per team: {$minPlayers}</li>";
         $html .= "<li>Max Players per team: {$maxPlayers}</li>";
         $html .= "<li>{$location}</li>";
         $html .= "<li>Winner of league: {$winner}</li>";
         $html .= "</ul>";
     } else {
         $league = $this->logicLayer->findLeague(null, $leagueId)->current();
         $leagueRules = $league->getLeagueRules();
         $matchRules = $league->getMatchRules();
         $minTeams = $league->getMinTeams();
         $maxTeams = $league->getMaxTeams();
         $minPlayers = $league->getMinMembers();
         $maxPlayers = $league->getMaxMembers();
         $location = $league->getIsIndoor() ? "Indoor" : "Outdoor";
         $winner = $league->getWinnerOfLeague() != null ? $league->getWinnerOfLeague()->getName() : "None";
         $html .= "<ul>";
         $html .= "<li>League rules: {$leagueRules}</li>";
         $html .= "<li>Match rules: {$matchRules}</li>";
         $html .= "<li>Min Teams: {$minTeams}</li>";
         $html .= "<li>Max Teams: {$maxTeams}</li>";
         $html .= "<li>Min Players per team: {$minPlayers}</li>";
         $html .= "<li>Max Players per team: {$maxPlayers}</li>";
         $html .= "<li>{$location}</li>";
         $html .= "<li>Winner of league: {$winner}</li>";
         $html .= "</ul>";
     }
     return $html;
 }