Last active
May 16, 2019 16:46
-
-
Save hngfu/4485621271ba2080607a6be1a5344e13 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
func main() { | |
let input = InputView.read() | |
if Validator.isLessThanNine(input) == false { return } | |
guard let convertedInput = Converter.toInt(input) else { return } | |
let burgers = GodOfHamburger.hamburger(with: convertedInput) | |
print(burgers) | |
} | |
main() | |
//값을 입력받는 책임만 가진다. | |
class InputView { | |
static func read() -> String { | |
return readLine() ?? "" | |
} | |
} | |
//값을 검증하는 책임만 가진다. | |
class Validator { | |
static func isLessThanNine(_ string: String) -> Bool { | |
let numbers = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9",] | |
return numbers.contains(string) | |
} | |
} | |
//타입을 변환시켜주는 책임만 가진다. | |
class Converter { | |
static func toInt(_ string: String) -> Int? { | |
return Int(string) | |
} | |
} | |
//개수에 맞게 햄버거를 반환해주는 책임만 가진다. | |
class GodOfHamburger { | |
static func hamburger(with number: Int) -> [String] { | |
return Array(repeating: "🍔", count: number) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment