codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
<?php interface WalkmanInterface { public function pressPlay(); } class Walkman implements WalkmanInterface{ public function pressPlay(){ echo "Playing some music on the Walkman..."; } } interface iPodInterface { public function touchPlay(); } class iPod implements iPodInterface{ public function touchPlay(){ echo "Playing some music on the iPod..."; } } class WalkmanAdapter implements iPodInterface { private $walkman; public function __construct(WalkmanInterface $walkman){ $this->walkman = $walkman; } public function touchPlay(){ $this->walkman->pressPlay(); } } class Person { public function listen(iPodInterface $ipod){ $ipod->touchPlay(); } } $person = new Person; $person->listen(new WalkmanAdapter(new Walkman));
Private
[
?
]
Run code
Submit