This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| protocol Country { | |
| func accept(visitor: CountryVisitor) | |
| } | |
| protocol CountryVisitor { | |
| func visit(country: India) | |
| func visit(country: Brazil) | |
| func visit(country: China) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| protocol Office { | |
| func officeSchedule() | |
| } | |
| protocol Employee { | |
| func work() | |
| func getPaid() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| protocol Strategy { | |
| func convert(number: Int) | |
| } | |
| class Convert { | |
| var strategy: Strategy | |
| var number: Int | |
| init(number: Int, strategy: Strategy) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| protocol Human { | |
| // MARK: - Getter | |
| func getState() -> ManState | |
| // MARK: - Setter | |
| func set(state: ManState) | |
| } | |
| protocol ManState { | |
| func stand() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| protocol Observable { | |
| func add(customer: Observer) | |
| func remove(customer : Observer) | |
| func notify() | |
| } | |
| protocol Observer { | |
| var id: Int { get set } | |
| func update() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| typealias MementoType = [String: Any] | |
| protocol Memento: class { | |
| var key: String { get set } | |
| var state: MementoType { get set } | |
| func save() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| protocol Receiver { | |
| var name: String { get } | |
| func receive(message: String) | |
| } | |
| protocol Sender { | |
| var teams: [Receiver] { get set } | |
| func send(message: String, sender: Receiver) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct MyBestFilms: Sequence { | |
| let films: [String] | |
| func makeIterator() -> MyBestFilmsIterator { | |
| return MyBestFilmsIterator(films) | |
| } | |
| } | |
| struct MyBestFilmsIterator: IteratorProtocol { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| protocol Command { | |
| func execute() | |
| } | |
| class ConcreteCommand: Command { | |
| var colorReceiver: ColorReceiver | |
| init(colorReceiver: ColorReceiver) { | |
| self.colorReceiver = colorReceiver |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| enum Level: Int { | |
| case state = 1 | |
| case national = 2 | |
| case international = 3 | |
| } | |
| class Sports { | |
| var level: Level | |
NewerOlder