Skip to content

Commit 4fd08b9

Browse files
committed
Development complete. Initiate testing.
1 parent a3cd432 commit 4fd08b9

File tree

7 files changed

+149
-0
lines changed

7 files changed

+149
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
//Client.php
3+
include_once('CountryFactory.php');
4+
include_once('KyrgyzstanProduct.php');
5+
class Client
6+
{
7+
private $countryFactory;
8+
public function __construct()
9+
{
10+
$this->countryFactory=new CountryFactory();
11+
echo $this->countryFactory->doFactory(new KyrgyzstanProduct());
12+
}
13+
}
14+
$worker=new Client();
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
//CountryFactory.php
4+
include_once('Creator.php');
5+
include_once('Product.php');
6+
class CountryFactory extends Creator {
7+
8+
private $country;
9+
10+
protected function factoryMethod(Product $product) {
11+
$this->country=$product;
12+
return($this->country->getProperties());
13+
}
14+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
abstract class Creator {
4+
5+
protected abstract function factoryMethod(Product $product);
6+
7+
public function doFactory($productNow) {
8+
$countryProduct=$productNow;
9+
$mfg= $this->factoryMethod($countryProduct);
10+
return $mfg;
11+
}
12+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
class FormatHelper {
4+
5+
private $topper;
6+
7+
private $bottom;
8+
9+
public function addTop() {
10+
$this->topper="<!doctype html><html><head>
11+
<link rel='stylesheet' type='text/css' href='products.css'/>
12+
<meta charset='UTF-8'>
13+
<title>Map Factory</title>
14+
</head>
15+
<body>";
16+
return $this->topper;
17+
}
18+
19+
public function closeUp() {
20+
$this->bottom="</body></html>";
21+
return $this->bottom;
22+
}
23+
24+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
//TextProduct.php
3+
include_once('FormatHelper.php');
4+
include_once('Product.php');
5+
class KyrgyzstanProduct implements Product {
6+
7+
private $mfgProduct;
8+
9+
private $formatHelper;
10+
11+
public function getProperties() {
12+
$this->formatHelper=new FormatHelper();
13+
$this->mfgProduct=$this->formatHelper->addTop();
14+
$this->mfgProduct.=<<<KYRGYZSTAN
15+
<img src='Countries/Kyrgyzstan.png' class='pixRight' width='600'
16+
height='304'>
17+
<header>Kyrgyzstan</header>
18+
<p>A Central Asian country of incredible natural beauty and proud
19+
nomadic traditions, most of Kyrgyzstan was formally annexed to
20+
Russia in 1876. The Kyrgyz staged a major revolt against the
21+
Tsarist Empire in 1916 in which almost one-sixth of the Kyrgyz
22+
population was killed. Kyrgyzstan became a Soviet republic in 1936
23+
92 | Chapter 5: Factory Method Design Pattern
24+
and achieved independence in 1991 when the USSR dissolved. Nationwide
25+
demonstrations in the spring of 2005 resulted in the ouster of
26+
President Askar AKAEV, who had run the country since 1990.
27+
Subsequent presidential elections in July 2005 were won overwhelmingly
28+
by former prime minister Kurmanbek BAKIEV. Over the next few years,
29+
the new president manipulated the parliament to accrue new powers
30+
for himself. In July 2009, after months of harassment against
31+
his opponents and media critics, BAKIEV won re-election in a
32+
presidential campaign that the international community deemed
33+
flawed. In April 2010, nationwide protests led to the resignation
34+
and expulsion of BAKIEV. His successor, Roza OTUNBAEVA, served as
35+
transitional president until Almazbek ATAMBAEV was inaugurated in
36+
December 2011. Continuing concerns include: the trajectory of
37+
democratization, endemic corruption, poor interethnic relations,
38+
and terrorism.
39+
</p>
40+
KYRGYZSTAN;
41+
$this->mfgProduct .=$this->formatHelper->closeUp();
42+
return $this->mfgProduct;
43+
}
44+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
//Product.php
3+
interface Product {
4+
5+
public function getProperties();
6+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
To change this license header, choose License Headers in Project Properties.
3+
To change this template file, choose Tools | Templates
4+
and open the template in the editor.
5+
*/
6+
/*
7+
Created on : Nov 13, 2013, 10:09:58 AM
8+
Author : Anit Shrestha
9+
*/
10+
11+
@charset "UTF-8";
12+
/* CSS Document */
13+
img
14+
{
15+
padding: 10px 10px 10px 0px;
16+
}
17+
.pixRight
18+
{
19+
float:right; margin: 0px 0px 5px 5px;
20+
}
21+
.pixLeft
22+
{
23+
float:left; margin: 0px 5px 5px 0px;
24+
}
25+
header
26+
{
27+
color:#900;
28+
font-size:24px;
29+
font-family:"Arial Black", Gadget, sans-serif;
30+
}
31+
body
32+
{
33+
font-family:Verdana, Geneva, sans-serif;
34+
font-size:12px;
35+
}

0 commit comments

Comments
 (0)