<?php
interface Strategy
{
public function showAd();
public function showGt();
}
require_once "Strategy.php";
class MaleGrategy implements Strategy
{
public function showAd()
{
echo "Male Ad<br/>";
}
public function showGt()
{
echo "Male Gt<br/>";
}
}
require_once "Strategy.php";
class FemaleGrategy implements Strategy
{
public function showAd()
{
echo "Female Ad<br/>";
}
public function showGt()
{
echo "Female Gt<br/>";
}
}
require_once "MaleGrategy.php";
require_once "FemaleGrategy.php";
class Index
{
public $object;
public function setStrategy($object)
{
$this->object = $object;
}
public function showAd()
{
$this->object->showAd();
}
public function showGt()
{
$this->object->showGt();
}
}
if(isset($_GET['type']) && $_GET['type'] == "male")
{
$object = new MaleGrategy();
} else {
$object = new FemaleGrategy();
}
$index = new Index();
$index->setStrategy($object);
$index->showAd();
$index->showGt();
?>
interface Strategy
{
public function showAd();
public function showGt();
}
require_once "Strategy.php";
class MaleGrategy implements Strategy
{
public function showAd()
{
echo "Male Ad<br/>";
}
public function showGt()
{
echo "Male Gt<br/>";
}
}
require_once "Strategy.php";
class FemaleGrategy implements Strategy
{
public function showAd()
{
echo "Female Ad<br/>";
}
public function showGt()
{
echo "Female Gt<br/>";
}
}
require_once "MaleGrategy.php";
require_once "FemaleGrategy.php";
class Index
{
public $object;
public function setStrategy($object)
{
$this->object = $object;
}
public function showAd()
{
$this->object->showAd();
}
public function showGt()
{
$this->object->showGt();
}
}
if(isset($_GET['type']) && $_GET['type'] == "male")
{
$object = new MaleGrategy();
} else {
$object = new FemaleGrategy();
}
$index = new Index();
$index->setStrategy($object);
$index->showAd();
$index->showGt();
?>