-
Notifications
You must be signed in to change notification settings - Fork 63
dz гб #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
dz гб #2
Conversation
| import java.util.List; | ||
|
|
||
| public class Human { | ||
| private int id = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
инициализацию лучше делать в конструкторе класса
| private int age; | ||
| private String name; | ||
| private String surname; | ||
| private MotFath MotFath; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
имена переменных с маленькой буквы. И это видимо родители? Так и назовите Parents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Создать поля типа Human для ссылки на родителей
| @Override | ||
| public String toString() { | ||
| return ", name: " + name + ", surname: " + surname + ", age: " + age + ", gender: " + gender | ||
| + ", status: " + MotFath + ", children: " + children; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
а id?
| public class Human { | ||
| private int id = 1; | ||
| private Gender gender; | ||
| private int age; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
говорил на семинаре, что это неверно. Возраст постоянно меняется. Правильней указать дату рождения и смерти, а возраст высчитывать в методе
| public enum MotFath { | ||
| Father, Mother, Child; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А... это не только родители родители? Тогда надо написать, что это роль в семье или вроде того, но честно не знаю как вы будете это использовать, сейчас глянем
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Да, посмотрел. Это ошибка. Данные понятия относительны. Для кого то человек является матерью, а для кого то тот же самый человек является внучкой, а объект один и вы не можете присвоить ему сразу несколько значений enum
| private String name; | ||
| private String surname; | ||
| private MotFath MotFath; | ||
| private List<String> children; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Список детей должен быть не String содержать, а Human
| StringBuilder stringBuilder = new StringBuilder(); | ||
| stringBuilder.append("Список человек в генеалогическом древе: \n"); | ||
| for (Human Human : humanList){ | ||
| stringBuilder.append("id " + id++); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Этого тоже не понял. id это же значение дерева? Почему оно вдруг увеличивается? и зачем каждый раз писать перед выдачей информации по людям. И это значение не обнуляется, значит если несколько раз попросить выписку по семье, то id будет меняться у тех же записей, а это уж совсем неправильно
Александр Шугалей