<?php
require_once 'AbstractTrain.php';
require_once 'Train.php';
require_once 'Wagon.php';
$newTrain = new Train('Train M1');
$newTrain->addWagon(new Wagon('Wagon 1'));
$newTrain->addWagon(new Wagon('Wagon 2'));
$newTrain->addWagon(new Wagon('Wagon 3'));
$newWagon = new Wagon('Wagon M4');
//U can't add a train to a wagon
$newWagon->addWagon($newTrain);
//Check Train and Wagon
$newTrain->check();
echo "<br />";
$newWagon->check();
|