/
FreeZZZeee
/
tenth_lesson
Обзор
Документация
Войти
/
FreeZZZeee
/
tenth_lesson
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/PasswordChecker.java
43 строки
1 KB
ЛЕОНИД ВИТАЛЬЕВИЧ ЯКОВЛЕВ
first_commit
12 фев 2026, 11:47
12 фев 2026, 11:47
6ef8bde
Код
Авторство
О чём код?
import java.util.Arrays; public class PasswordChecker { private int minLength; private int maxRepeats; public void setMinLength(int minLength) { if (minLength < 0) { throw new IllegalArgumentException("Пароль не должен быть отрицательным!"); } this.minLength = minLength; } public void setMaxRepeats(int maxRepeats) { if (maxRepeats <= 0) { throw new IllegalArgumentException("Пароль не должен быть отрицательным и равен 0!"); } this.maxRepeats = maxRepeats; } private int getMinLength() { return this.minLength; } private int getMaxRepeats() { return this.maxRepeats; } public boolean verify(String password) { int[] charCounts = new int[256]; for (int i = 0; i < password.length(); i++) { char c = password.charAt(i); charCounts[c]++; } for (int charCount : charCounts) { if (charCount > this.getMaxRepeats() || password.length() > this.getMinLength()) { return false; } } return true; } }