Пример #1
0
<?php

require_once './IngredientFactory.php';
require_once './IPhoneFactory.php';
require_once './AndroidFactory.php';
require_once './PhoneFactory.php';
require_once './OS.php';
require_once './IPhoneOS.php';
require_once './AndroidOS.php';
require_once './Special.php';
require_once './IPhoneSpecial.php';
require_once './AndroidSpecial.php';
$iPhoneFactory = new IPhoneFactory();
$iphone_os = $iPhoneFactory->createOS("ios");
echo $iphone_os->create();
$iphone_special = $iPhoneFactory->createSpecial("siri");
echo $iphone_special->create();
$androidFactory = new AndroidFactory();
$android_os = $androidFactory->createOS("android");
echo $android_os->create();
$android_special = $iPhoneFactory->createSpecial("nfc");
echo $android_special->create();
Пример #2
0
<?php

require_once './PhoneFactory.php';
require_once './Phone.php';
require_once './IPhoneFactory.php';
require_once './IPhone.php';
require_once './Android.php';
require_once './AndroidFactory.php';
require_once './OtherFactory.php';
require_once './Other.php';
$iphoneFactory = new IphoneFactory();
$androidFactory = new AndroidFactory();
$otherFactory = new OtherFactory();
$iphone = $iphoneFactory->createPhone();
echo "Get phone " . $iphone->getName() . "\n";
$android = $androidFactory->createPhone();
echo "Get phone " . $android->getName() . "\n";
$other = $otherFactory->createPhone();
echo "Get phone " . $other->getName() . "\n";