Skip to content

Commit 2f91878

Browse files
committed
Example implementaion of Factory parameterized completed.
1 parent 4fd08b9 commit 2f91878

File tree

3 files changed

+60
-2
lines changed

3 files changed

+60
-2
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<?php
22
//Client.php
33
include_once('CountryFactory.php');
4-
include_once('KyrgyzstanProduct.php');
4+
include_once('MoldovaProduct.php');
55
class Client
66
{
77
private $countryFactory;
88
public function __construct()
99
{
1010
$this->countryFactory=new CountryFactory();
11-
echo $this->countryFactory->doFactory(new KyrgyzstanProduct());
11+
echo $this->countryFactory->doFactory(new MoldovaProduct());
1212
}
1313
}
1414
$worker=new Client();
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<img src='Countries/Kyrgyzstan.png' class='pixRight' width='600'
2+
height='304'>
3+
<header>Kyrgyzstan</header>
4+
<p>A Central Asian country of incredible natural beauty and proud
5+
nomadic traditions, most of Kyrgyzstan was formally annexed to
6+
Russia in 1876. The Kyrgyz staged a major revolt against the
7+
Tsarist Empire in 1916 in which almost one-sixth of the Kyrgyz
8+
population was killed. Kyrgyzstan became a Soviet republic in 1936
9+
92 | Chapter 5: Factory Method Design Pattern
10+
and achieved independence in 1991 when the USSR dissolved. Nationwide
11+
demonstrations in the spring of 2005 resulted in the ouster of
12+
President Askar AKAEV, who had run the country since 1990.
13+
Subsequent presidential elections in July 2005 were won overwhelmingly
14+
by former prime minister Kurmanbek BAKIEV. Over the next few years,
15+
the new president manipulated the parliament to accrue new powers
16+
for himself. In July 2009, after months of harassment against
17+
his opponents and media critics, BAKIEV won re-election in a
18+
presidential campaign that the international community deemed
19+
flawed. In April 2010, nationwide protests led to the resignation
20+
and expulsion of BAKIEV. His successor, Roza OTUNBAEVA, served as
21+
transitional president until Almazbek ATAMBAEV was inaugurated in
22+
December 2011. Continuing concerns include: the trajectory of
23+
democratization, endemic corruption, poor interethnic relations,
24+
and terrorism.
25+
</p>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
/*
4+
* To change this license header, choose License Headers in Project Properties.
5+
* To change this template file, choose Tools | Templates
6+
* and open the template in the editor.
7+
*/
8+
9+
//MoldovaProduct.php
10+
include_once('FormatHelper.php');
11+
include_once('Product.php');
12+
class MoldovaProduct implements Product {
13+
14+
private $mfgProduct;
15+
16+
private $formatHelper;
17+
18+
private $countryNow;
19+
20+
public function getProperties() {
21+
//Loads text writeup from external text file
22+
$this->countryNow = file_get_contents("CountryWriteups/Moldova.txt");
23+
$this->formatHelper=new FormatHelper();
24+
$this->mfgProduct=$this->formatHelper->addTop();
25+
$this->mfgProduct.="<img src='Countries/Moldova.png' class='pixRight'
26+
width='208' height='450'>";
27+
$this->mfgProduct .="<header>Moldova</header>";
28+
$this->mfgProduct .="<p>$this->countryNow</p>";
29+
$this->mfgProduct .=$this->formatHelper->closeUp();
30+
return $this->mfgProduct;
31+
}
32+
33+
}

0 commit comments

Comments
 (0)