Login   Register  
PHP Classes
elePHPant
Icontem

File: index.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Bogdan T. Gersak  >  Composite Pattern  >  index.php  >  Download  
File: index.php
Role: Example script
Content type: text/plain
Description: How to use it
Class: Composite Pattern
Implementation of the composite design pattern
Author: By
Last change:
Date: 4 years ago
Size: 460 bytes
 

Contents

Class file image Download
<?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();