December 2018
Intermediate to advanced
414 pages
10h 19m
English
The main controller will be called GameController, because it manages everything about the current game.
It creates an instance of the QuestionController from the model layer, and an instance of a ViewController from the view layer:
class GameController { private let questions = QuestionController() private let view = ViewController() private func waitForAnswer(question: Question) { // Wait for user input let result = readLine() // Ask the model if answer is good if question.isGoodAnswer(result: result) { // Update the view view.goodAnswer() } else { view.badAnswer() } } func start() { // From the model layer, get the next question while let question = questions.next() { // Display the question on screen view.ask(question: ...
Read now
Unlock full access