cs AbstractFactory

This commit is contained in:
Dominik Liebler
2013-09-09 10:39:41 +02:00
parent 8c520c39c3
commit 3b7eb295c8
15 changed files with 39 additions and 52 deletions

View File

@@ -7,20 +7,22 @@
namespace DesignPatterns\Adapter;
/**
* ElecBookAdapter is an adapter to fit an e-book like a paper book
* EBookAdapter is an adapter to fit an e-book like a paper book
*
* This is the adapter here. Notice it implemennts PaperBookInterface,
* therefore you don't have to change the code of the client which using paper book.
*/
class ElecBookAdapter implements PaperBookInterface
class EBookAdapter implements PaperBookInterface
{
protected $eBook;
/**
* Notice the constructor, it "wraps" an electronic book
*
* @param EBookInterface $ebook
*/
public function __construct(ElecBookInterface $ebook)
public function __construct(EBookInterface $ebook)
{
$this->eBook = $ebook;
}
@@ -33,9 +35,11 @@ class ElecBookAdapter implements PaperBookInterface
$this->eBook->pressStart();
}
/**
* turns pages
*/
public function turnPage()
{
$this->eBook->pressNext();
}
}
}

View File

@@ -0,0 +1,14 @@
<?php
namespace DesignPatterns\Adapter;
/**
* EBookInterface is a contract for an electronic book
*/
interface EBookInterface
{
function pressNext();
function pressStart();
}

View File

@@ -1,18 +0,0 @@
<?php
/*
* DesignPatternPHP
*/
namespace DesignPatterns\Adapter;
/**
* ElecBookInterface is a contract for an electronic book
*/
interface ElecBookInterface
{
function pressNext();
function pressStart();
}