DE
Size: a a a
DE
AV
DE
DE
SM
AV
class Championship
{
private array $teams;
public function addTeam(int $teamId, array $players)
{
// как сюда передать игроков, если им нужна команда, которой еще не существует???
$this->teams[] = new Team($teamId, $players, $this);
}
}
class Team
{
private int $id;
private array $players;
private Championship $championship;
public function __construct(int $id, array $players, Championship $championship)
{
$this->id = $id;
$this->players = $players;
$this->championship = $championship;
if (count($players) !== 11) {
// кидаем исключение, что игроков неверное количество
}
}
public function addPlayer($playerId)
{
$this->players[] = new Player($playerId, $this);
}
}
class Player
{
private $id;
private Team $team;
public function __construct($id, Team $team)
{
$this->id = $id;
$this->team = $team;
}
}
AV
SM
AV
SM
SM
AV
SM
AV
IM
IM
AV
AV
if (count($players) !== 11) {
// кидаем исключение, что игроков неверное количество
}
IM
RL