Skip to content

Project1 - #2

Open
V0S7ER wants to merge 4 commits into
mainfrom
project1
Open

Project1#2
V0S7ER wants to merge 4 commits into
mainfrom
project1

Conversation

@V0S7ER

@V0S7ER V0S7ER commented Oct 22, 2023

Copy link
Copy Markdown
Owner

No description provided.

@SHvatov SHvatov left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@V0S7ER пара минорных комментариев, в остальном все ок. Вот только тестов не хватает, поэтому если хочешь полный балл — их нужно будет добавить.

Session session = new Session(dictionary.getWord(), MAX_ATTEMPTS);

GuessResult lastResult = null;
while (!(lastResult instanceof GuessResult.Win) && (!(lastResult instanceof GuessResult.Defeat))) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я бы просто добавил в GuessResult метод isTerminal - делать проверки через instanceof не самое лучшее решение, особенно с точки зрения дальнейшей поддержки. К примеру, мы захотим добавить терминальный статус — досрочное поражение, и главное будет не забыть его добавить в это условие.

import org.jetbrains.annotations.NotNull;

public sealed interface GuessResult {
@SuppressWarnings("unused")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Если не используется, то можно удалить

this.guessCount = 0;
}

@NotNull GuessResult guess(String guess) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Аннотация убежала

}

char guessLetter = guess.charAt(0);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Пустые строки ни к чему


@NotNull GuessResult guess(String guess) {
if (guess.length() != 1) {
return new GuessResult.IncorrectGuess(userAnswer, attempts, maxAttempts);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут же можно проверить, что guess.charAt(0) от a до z

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants