/
Nicholas
/
java_basics
Обзор
Документация
Войти
/
Nicholas
/
java_basics
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
Performance/VoteAnalyzer/src/Voter.java
41 строка
940 B
nikolai_sokolovskii
20.2 VoteAnalyser
23 дек 2023, 21:56
23 дек 2023, 21:56
ae43e96
Код
Авторство
О чём код?
import java.text.SimpleDateFormat; import java.util.Date; public class Voter { private String name; private String birthDay; public Voter(String name, String birthDay) { this.name = name; this.birthDay = birthDay; } @Override public boolean equals(Object obj) { Voter voter = (Voter) obj; return name.equals(voter.name) && birthDay.equals(voter.birthDay); } @Override public int hashCode() { long code = name.hashCode() + birthDay.hashCode(); while (code > Integer.MAX_VALUE) { code = code / 10; } return (int) code; } public String toString() { SimpleDateFormat dayFormat = new SimpleDateFormat("yyyy.MM.dd"); return name + " (" + dayFormat.format(birthDay) + ")"; } public String getName() { return name; } public String getBirthDay() { return birthDay; } }