Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
<?php
require_once 'MatchHistory.php';
class Player {
// declare class member variables
var $name;
var $matchHistory;
// constructor
function Player($name, $gamesPlayed, $goalsScored) {
$this->name = $name;
$this->matchHistory = new MatchHistory($gamesPlayed, $goalsScored);
}
function getName() {
return $this->name;
}
function getMatchHistory() {
return $this->matchHistory;
}
}
?>
<?php
class MatchHistory {
// declare class member variables
var $gamesPlayed;
var $goalsScored;
// constructor
function MatchHistory($gamesPlayed, $goalsScored) {
$this->gamesPlayed = $gamesPlayed;
$this->goalsScored = $goalsScored;
}
// calculate goals per game ratio
function GoalsPerGame() {
return ($this->goalsScored / $this->gamesPlayed);
}
}
?>
<?php
require_once 'Player.php';
$myPlayer = new Player('David Beckham', 28, 3);
$playerMatchHistory = $myPlayer->getMatchHistory();
echo $myPlayer->getName() . ' scored ' . $playerMatchHistory->GoalsPerGame() . ' goals per game';
?>