Created
July 9, 2020 22:33
-
-
Save Kdan/ff9f919b217f09c8ce99e6bc6ff534f1 to your computer and use it in GitHub Desktop.
This file contains 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 Presenter { | |
/// Present the given content to the user. | |
func present(title: String, description: String) | |
} | |
class ContentHandler { | |
/// The presenter used to present content. | |
private let presenter: Presenter | |
init(presenter: Presenter) { | |
self.presenter = presenter | |
} | |
/// Handles the input and present the corresponding content to the user. | |
func handleInput(_ input: Int) { | |
let title: String | |
let description: String | |
switch input { | |
case Int.min...0: | |
title = "Negative" | |
description = "Less than zero" | |
case 0...10: | |
title = "Positive" | |
description = "Great input" | |
default: | |
title = "Too high" | |
description = "...Way too high" | |
} | |
presenter.present(title: title, description: description) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment