/
Arsalan
/
Exceptions
Обзор
Документация
Войти
/
Arsalan
/
Exceptions
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
PasswordChecker.java
44 строки
1 KB
Arsalan
upload files
08 сен 2025, 15:58
08 сен 2025, 15:58
ce43af5
Код
Авторство
О чём код?
import com.sun.jdi.IntegerValue; public class PasswordChecker { public int minLength=0; public int maxLength=0; public void setMinLength(int minLength) { if (minLength <= 0) { throw new IllegalArgumentException("Длина пароля должна быть больше 0"); }else{ this.minLength = minLength; } } public void setMaxLength(int maxLength) { if (maxLength <= 0) { throw new IllegalArgumentException("Количество повторений не должно быть меньше 0"); }else{ this.maxLength = maxLength; } } public boolean verify(String password){ if (password.length() >= minLength){ int count = 0; int maxCount = 0; for (int i = 0; i < password.length()-1; i++) { if (password.charAt(i) == password.charAt(i+1)){ count++; if (count > maxCount){ maxCount = count; } }else{ count=0; } } if (maxCount > maxLength){ return false; }else{ return true; } } else { return false; } } }