access another class protected variable in PHP

Im writing a football manager simulator with php, [ HARD AlGORITHMS !]i have 3 class :Player\[code\]class Player {protected $name;public function addAttr($name) { $this->name = $name;}}\[/code\]Team\[code\]class Team {protected $name;protected $players = array();public function setName($name) { $this->name = $name;}public function getName() { return $this->name;}public function addPlayer($player) { $this->players[] = $player;}public function getPlayers() { print_r($this->players);}public function getOpponetsPosition() { GAME::getOpponetPlayersPosition();}\[/code\]and Game \[code\]class Game {protected $t1;protected $t2;function setTeams($team1,$team2) { $this->t1 = $team1; $this->t2 = $team2;}function getOpponetPlayersPosition() { $this->t1->getPlayers();}\[/code\]}and main script\[code\]require_once 'classes/CPlayer.php';require_once 'classes/CTeam.php';require_once 'classes/CGame.php';$game = new Game;$team1 = new Team;$team1->setName("PO-1");$team2 = new Team;$team2->setName("PO-2");$p1 = new Player;$p2 = new Player;$p1->addAttr("payam babaiy");$p2->addAttr("parsa babaiy");$team1->addPlayer($p1);$team2->addplayer($p2);$game->setTeams($team1,$team2);$team1->getOpponetsPosition();\[/code\]I Need to get all player positions in game with getOpponetsPosition() function in Team classbut it doesnt return values which i inputed in my main script.am i doing this right ? is this a good approach for app im writing ?
 
Back
Top