8000 Fixed - Formatting - Chapter1.md · sockstack/design-patterns-by-php@9e0fcba · GitHub
[go: up one dir, main page]

Skip to content

Commit 9e0fcba

Browse files
author
Bruce Liu
committed
Fixed - Formatting - Chapter1.md
1 parent 99d27e0 commit 9e0fcba

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

files/chapter1.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
```php
55
<?php
66

7+
/**
8+
* Operation
9+
*/
710
class Operation
811
{
912
protected $a = 0;
@@ -27,8 +30,8 @@ class Operation
2730
}
2831

2932
/**
30-
* add
31-
*/
33+
* Add
34+
*/
3235
class OperationAdd extends Operation
3336
{
3437
public function getResult()
@@ -38,8 +41,8 @@ class OperationAdd extends Operation
3841
}
3942

4043
/**
41-
* Mul
42-
*/
44+
* Mul
45+
*/
4346
class OperationMul extends Operation
4447
{
4548
public function getResult()
@@ -49,8 +52,8 @@ class OperationMul extends Operation
4952
}
5053

5154
/**
52-
* sub
53-
*/
55+
* Sub
56+
*/
5457
class OperationSub extends Operation
5558
{
5659
public function getResult()
@@ -60,8 +63,8 @@ class OperationSub extends Operation
6063
}
6164

6265
/**
63-
* div
64-
*/
66+
* Div
67+
*/
6568
class OperationDiv extends Operation
6669
{
6770
public function getResult()
@@ -70,10 +73,9 @@ class OperationDiv extends Operation
7073
}
7174
}
7275

73-
7476
/**
75-
* operation factory
76-
*/
77+
* Operation Factory
78+
*/
7779
class OperationFactory
7880
{
7981
public static function createOperation($operation)
@@ -92,14 +94,16 @@ class OperationFactory
9294
$oper = new OperationMul();
9395
break;
9496
}
97+
9598
return $oper;
9699
}
97100
}
101+
98102
// 客户端代码
99103
$operation = OperationFactory::createOperation('+');
100104
$operation->setA(1);
101105
$operation->setB(2);
102-
echo $operation->getResult()."\n";
106+
echo $operation->getResult() . PHP_EOL;
103107
```
104108

105109

0 commit comments

Comments
 (0)
0