-
Notifications
You must be signed in to change notification settings - Fork 692
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sprint 7 #742
base: project_sprint_3_start
Are you sure you want to change the base?
Sprint 7 #742
Conversation
…з систему контроля версий
Изменен вывод в консоль в файле AppDelegate
Task of the 4 sprint
home work sprint 5
Co-authored-by: averpovskii <[email protected]>
|
||
import UIKit | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Импортирование UIKit в презентере - признак того, что часть работы с UI просочилась в презентер.
Было бы здорово оставить тут import Foundation
и исправить возникшие ошибки (например, передать в контроллер data и уже в нем сгенерировать UIImage).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Благодарю, поправлю :)
// MARK: - Private Properties | ||
private final var questionFactory: QuestionFactoryProtocol? | ||
private weak var viewController: MovieQuizViewControllerProtocol? | ||
private final var statisticService: StatisticServiceProtocol? | ||
private var currentQuestion: QuizQuestion? | ||
|
||
private var currentQuestionIndex: Int = 0 | ||
private var correctAnswers: Int = 0 | ||
private let questionsAmount: Int = 10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Здорово, что ты используешь комментарии // MARK: - ..., а также не забываешь добавлять private 🔥
struct ArithmeticOperations { | ||
func addition(num1: Int, num2: Int, handler: @escaping(Int) -> Void) { | ||
DispatchQueue.global().asyncAfter(deadline: .now() + 1.0, execute: DispatchWorkItem(block: { | ||
handler(num1 + num2) | ||
})) | ||
} | ||
|
||
func subtraction(num1: Int, num2: Int, handler: @escaping(Int) -> Void) { | ||
DispatchQueue.global().asyncAfter(deadline: .now() + 1.0, execute: DispatchWorkItem(block: { | ||
handler(num1 - num2) | ||
})) | ||
} | ||
|
||
func multiplication(num1: Int, num2: Int, handler: @escaping(Int) -> Void) { | ||
DispatchQueue.global().asyncAfter(deadline: .now() + 1.0, execute: DispatchWorkItem(block: { | ||
handler(num1 * num2) | ||
})) | ||
} | ||
} | ||
|
||
final class MovieQuizTests: XCTestCase { | ||
|
||
func testAddition() throws { | ||
|
||
//MARK: Given | ||
let arithmeticOperations = ArithmeticOperations() | ||
let num1 = 1 | ||
let num2 = 2 | ||
|
||
//MARK: When | ||
let expectation = expectation(description: "Addition function expectation") | ||
|
||
arithmeticOperations.addition(num1: num1, num2: num2) { result in | ||
//MARK: Then | ||
XCTAssertEqual(result, 3) | ||
expectation.fulfill() | ||
} | ||
|
||
waitForExpectations(timeout: 2) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻👍🏻👍🏻
private func didAnswer(isCorrectAnswer: Bool){ | ||
if (isCorrectAnswer) { correctAnswers += 1 } | ||
} | ||
|
||
func yesButtonClicked() { | ||
didAnswer(isYes: true) | ||
} | ||
|
||
func noButtonClicked() { | ||
didAnswer(isYes: false) | ||
} | ||
|
||
private func createMessage() -> String { | ||
guard let statisticService else { return "" } | ||
let bestGame = statisticService.bestGame | ||
let result: String = "Ваш результат: \(correctAnswers)/\(questionsAmount)" | ||
let count: String = "Количество сыгранных игр: \(statisticService.gamesCount)" | ||
let record: String = "Рекорд: \(bestGame.correct)/\(bestGame.total) (\(bestGame.date.dateTimeString))" | ||
let totalAccuracy: String = "Средняя точность: \(String(format: "%.2f", statisticService.totalAccuracy))%" | ||
return [result, count, record, totalAccuracy].joined(separator: "\n") | ||
} | ||
|
||
func didLoadDataFromServer() { | ||
viewController?.hideLoadingIndicator() | ||
questionFactory?.requestNextQuestion() | ||
} | ||
|
||
func didFailToLoadData(with error: Error) { | ||
viewController?.showNetworkError(message: error.localizedDescription) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Приватные методы обычно принято располагать ниже обычных.
Про организацию кода можно дополнительно посмотреть в этой статье.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Благодарю, поправлю :)
No description provided.