/
kanisavi
/
Course_exceptions
Обзор
Документация
Войти
/
kanisavi
/
Course_exceptions
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
PasswordChecker.java
33 строки
1 KB
Карина Басова
update PasswordChecker.java
28 дек 2025, 14:40
28 дек 2025, 14:40
38b5afa
Код
Авторство
О чём код?
public class PasswordChecker { private int minLength; private int maxRepeats; public void setMinLength(int minLength) throws IllegalArgumentException { if (minLength <= 0) { throw new IllegalArgumentException("Недопустимое значение!"); } this.minLength = minLength; } public void setMaxRepeats(int maxRepeats) throws IllegalArgumentException { if (maxRepeats <= 0) { throw new IllegalArgumentException("Недопустимое значение!"); } this.maxRepeats = maxRepeats; } public boolean verify(String password) { int count = 1; if (password.length() < minLength) { return false; } for (int i = 1; i < password.length(); i++) { if (password.charAt(i) == password.charAt(i - 1)) { count++; } else { count = 1; } } return count <= maxRepeats; } }