/
Emma
/
enterprise_test
Обзор
Документация
Войти
/
Emma
/
enterprise_test
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/Person.java
39 строк
2 KB
Emma Kerimkhanova
fixes
24 окт 2025, 14:36
24 окт 2025, 14:36
b69959c
Код
Авторство
О чём код?
import java.time.LocalDate; import java.time.Period; public class Person { private int id; private FullName fullName; private Address address; private String telNumber; private LocalDate dateOfBirth; private PersonDocuments documents; public Person(int id, FullName fullName, Address address, String telNumber, LocalDate dateOfBirth, PersonDocuments documents) { if (id <= 0) throw new IllegalArgumentException("ID человека должен быть положительным"); if (fullName == null) throw new IllegalArgumentException("ФИО обязательно"); if (address == null) throw new IllegalArgumentException("Адрес обязателен"); if (telNumber == null || telNumber.isBlank()) throw new IllegalArgumentException("Телефон обязателен"); if (dateOfBirth == null) throw new IllegalArgumentException("Дата рождения обязательна"); LocalDate now = LocalDate.now(); int years = Period.between(dateOfBirth, now).getYears(); if (years < 18 || years > 100) throw new IllegalArgumentException("Некорректный возраст: " + years); if (documents == null) throw new IllegalArgumentException("Документы обязательны"); this.id = id; this.fullName = fullName; this.address = address; this.telNumber = telNumber; this.dateOfBirth = dateOfBirth; this.documents = documents; } }