Skip to content

Commit 51664ae

Browse files
committed
Minimal Example Comleted
1 parent ab0f5b9 commit 51664ae

File tree

4 files changed

+86
-0
lines changed

4 files changed

+86
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
/**
10+
* Description of AbstractClass
11+
*
12+
* @author Anit Shrestha
13+
*/
14+
abstract class AbstractClass {
15+
16+
protected $pix;
17+
18+
protected $cap;
19+
20+
public function templateMethod($pixNow, $capNow) {
21+
$this->pix=$pixNow;
22+
$this->cap=$capNow;
23+
$this->addPix($this->pix);
24+
$this->addCaption($this->cap);
25+
}
26+
27+
abstract protected function addPix($pix);
28+
29+
abstract protected function addCaption($cap);
30+
31+
}
32+
?>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
function __autoload($class_name) {
10+
include $class_name . '.php';
11+
}
12+
13+
class Client {
14+
15+
function __construct() {
16+
$caption="Modigliani painted elongated faces.";
17+
18+
$mo=new ConcreteClass();
19+
$mo->templateMethod("genious.jpg", $caption);
20+
}
21+
}
22+
23+
$worker=new Client();
24+
?>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
/**
10+
* Description of ConcreteClass
11+
*
12+
* @author Anit Shrestha
13+
*/
14+
include_once('AbstractClass.php');
15+
16+
class ConcreteClass extends AbstractClass {
17+
18+
protected function addPix($pix) {
19+
$this->pix=$pix;
20+
$this->pix = "pix/" . $this->pix;
21+
$formatter = "<img src=$this->pix><br/>";
22+
echo $formatter;
23+
}
24+
25+
protected function addCaption($cap) {
26+
$this->cap=$cap;
27+
echo "<em>Caption:</em>" . $this->cap . "<br/>";
28+
}
29+
}
30+
?>
27.9 KB
Loading

0 commit comments

Comments
 (0)