Skip to content

Commit 0bf784c

Browse files
author
Oktawian Chojnacki
committed
Generated.
1 parent 2f007e8 commit 0bf784c

File tree

11 files changed

+84
-31
lines changed

11 files changed

+84
-31
lines changed

Design-Patterns.playground.zip

467 Bytes
Binary file not shown.

Design-Patterns.playground/Pages/Behavioral.xcplaygroundpage/Contents.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ The interpreter pattern is used to evaluate sentences in a language.
167167

168168
### Example
169169
*/
170+
170171
protocol IntegerExp {
171172
func evaluate(context: IntegerContext) -> Int
172173
func replace(character: Character, integerExp: IntegerExp) -> IntegerExp
@@ -284,6 +285,7 @@ The mediator pattern is used to reduce coupling between classes that communicate
284285

285286
### Example
286287
*/
288+
287289
class Colleague {
288290
let mediator: Mediator
289291

@@ -325,9 +327,11 @@ class ConcreteColleague: Colleague {
325327
print("Colleague received: \(message)")
326328
}
327329
}
330+
328331
/*:
329332
### Usage
330333
*/
334+
331335
let messagesMediator = MessageMediator()
332336
let user0 = ConcreteColleague(mediator: messagesMediator)
333337
let user1 = ConcreteColleague(mediator: messagesMediator)
@@ -403,6 +407,7 @@ gameState.weapon = "Crossbow"
403407
CheckPoint.saveState(gameState.toMemento())
404408

405409
gameState.restoreFromMemento(CheckPoint.restorePreviousState(keyName: "gameState2"))
410+
406411
/*:
407412
👓 Observer
408413
-----------
@@ -554,6 +559,7 @@ lower.printString("O tempora, o mores!")
554559

555560
var upper = Printer(strategy:UpperCaseStrategy())
556561
upper.printString("O tempora, o mores!")
562+
557563
/*:
558564
🏃 Visitor
559565
----------

Design-Patterns.playground/Pages/Structural.xcplaygroundpage/Contents.swift

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,7 @@ protocol Shape {
125125
}
126126
/*:
127127
Leafs
128-
*/
129-
128+
*/
130129
class Square : Shape {
131130
func draw(fillColor: String) {
132131
print("Drawing a Square with color \(fillColor)")
@@ -289,21 +288,21 @@ class CurrentComputer : DoorOperator {
289288

290289
func authenticateWithPassword(pass: String) -> Bool {
291290

292-
if pass != "pass" {
293-
return false
291+
guard pass == "pass" else {
292+
return false;
294293
}
295294

296295
computer = HAL9000()
297296

298297
return true
299298
}
300-
299+
301300
func openDoors(doors: String) -> String {
302301

303-
if computer == nil {
302+
guard computer != nil else {
304303
return "Access Denied. I'm afraid I can't do that."
305304
}
306-
305+
307306
return computer.openDoors(doors)
308307
}
309308
}

Design-Patterns.playground/contents.xcplayground

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
22
<playground version='6.0' target-platform='ios' requires-full-environment='true' display-mode='rendered'>
33
<pages>
4-
<page name='Patterns'/>
54
<page name='Behavioral'/>
65
<page name='Creational'/>
76
<page name='Structural'/>

0 commit comments

Comments
 (0)