Skip to content

Commit

Permalink
Изменён метод getPosition()
Browse files Browse the repository at this point in the history
  • Loading branch information
kalenchukov committed Aug 5, 2022
1 parent c0a9da9 commit b559130
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions src/main/java/dev/kalenchukov/alphabet/AbstractAlphabet.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public boolean hasLetter(@NotNull final Character letter)
{
Objects.requireNonNull(letter);

return this.getPosition(this.letters, letter) != null;
return this.getPosition(letter) != null;
}

/**
Expand All @@ -128,24 +128,9 @@ public Integer getPosition(@NotNull final Character letter)
{
Objects.requireNonNull(letter);

return this.getPosition(this.letters, letter);
}

/**
* Возвращает позицию буквы в алфавите.
*
* @param alphabet Алфавит.
* @param letter Буква.
* @return Позицию буквы в алфавите.
*/
@Nullable
protected Integer getPosition(@NotNull final List<@NotNull Character> alphabet, @NotNull final Character letter)
{
Objects.requireNonNull(letter);

for (int position = 0; position < alphabet.size(); position++)
for (int position = 0; position < this.letters.size(); position++)
{
if (alphabet.get(position).equals(letter)) {
if (this.letters.get(position).equals(letter)) {
return position + 1;
}
}
Expand Down

0 comments on commit b559130

Please sign in to comment.