/
Vickie
/
hw_password
Обзор
Документация
Войти
/
Vickie
/
hw_password
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
PasswordChecker.java
40 строк
1 KB
Vickie
Create: IllegalArgumentException.java, Main.java, PasswordChecker.java
05 июл 2026, 13:40
Верифицирован
05 июл 2026, 13:40
fce01ab
Код
Авторство
О чём код?
import java.util.Scanner; public class PasswordChecker { int minLength = 0; int maxRepeats = 0; Scanner scanner = new Scanner(System.in); public void setMinLength(int input) { if (input <= 0) { throw new IllegalArgumentException(input); } this.minLength = input; } public void setMaxRepeats(int input) { if (input <= 0) { throw new IllegalArgumentException(input); } this.maxRepeats = input; } boolean verify(String password) { int count = 0; boolean repeat = true; for (int i = 1; i < password.length(); i++) { if (password.charAt(i) == (password.charAt(i-1))) { count++; if (count >= maxRepeats) repeat = false; } else {count = 0; continue; } } if ((password.length() >= this.minLength) && (repeat)) return true; else return false; } }