<?php
class planesTrainsAutomobiles
{
public $where = 'New York';
public $to = 'Chicago';
public $plane = true;
public $train = true;
public $automobile = true;
public function show()
{
while($this->where != $this->to)
{
$this->where_am_i();
while($this->plane AND $this->where != $this->to)
$this->travel_by_plane();
$this->where_am_i();
while($this->train AND $this->where != $this->to)
$this->travel_by_train();
$this->where_am_i();
while($this->automobile AND $this->where != $this->to)
$this->travel_by_automobile();
$this->where_am_i();
}
$this->thanksgiving();
}
public function travel_by_plane()
{
echo 'Travelling by Plane<br />';
$this->where = 'New York';
$this->plane = false;
echo 'Plane is cancelled!<br />';
}
public function travel_by_train()
{
echo 'Travelling by Train<br />';
$this->where = 'Missouri';
$this->train = false;
echo 'Train engine is broken!<br />';
}
public function travel_by_automobile()
{
echo 'Travelling by Car<br />';
$this->where = 'Chicago';
}
public function where_am_i()
{
echo 'Where am i? '.$this->where.'<br />';
}
public function thanksgiving()
{
echo "<p>Home - it's party time!!</p>";
}
}
$film = new planesTrainsAutomobiles;
$film->show();
?>
class planesTrainsAutomobiles
{
public $where = 'New York';
public $to = 'Chicago';
public $plane = true;
public $train = true;
public $automobile = true;
public function show()
{
while($this->where != $this->to)
{
$this->where_am_i();
while($this->plane AND $this->where != $this->to)
$this->travel_by_plane();
$this->where_am_i();
while($this->train AND $this->where != $this->to)
$this->travel_by_train();
$this->where_am_i();
while($this->automobile AND $this->where != $this->to)
$this->travel_by_automobile();
$this->where_am_i();
}
$this->thanksgiving();
}
public function travel_by_plane()
{
echo 'Travelling by Plane<br />';
$this->where = 'New York';
$this->plane = false;
echo 'Plane is cancelled!<br />';
}
public function travel_by_train()
{
echo 'Travelling by Train<br />';
$this->where = 'Missouri';
$this->train = false;
echo 'Train engine is broken!<br />';
}
public function travel_by_automobile()
{
echo 'Travelling by Car<br />';
$this->where = 'Chicago';
}
public function where_am_i()
{
echo 'Where am i? '.$this->where.'<br />';
}
public function thanksgiving()
{
echo "<p>Home - it's party time!!</p>";
}
}
$film = new planesTrainsAutomobiles;
$film->show();
?>