Skip to content

Conversation

@zedtsu
Copy link

@zedtsu zedtsu commented Jul 1, 2023

Александр Шугалей

import java.util.List;

public class Human {
private int id = 1;
Copy link
Owner

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;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

имена переменных с маленькой буквы. И это видимо родители? Так и назовите Parents

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Создать поля типа Human для ссылки на родителей

Comment on lines +32 to +36
@Override
public String toString() {
return ", name: " + name + ", surname: " + surname + ", age: " + age + ", gender: " + gender
+ ", status: " + MotFath + ", children: " + children;
}
Copy link
Owner

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;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

говорил на семинаре, что это неверно. Возраст постоянно меняется. Правильней указать дату рождения и смерти, а возраст высчитывать в методе

Comment on lines +3 to +5
public enum MotFath {
Father, Mother, Child;
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А... это не только родители родители? Тогда надо написать, что это роль в семье или вроде того, но честно не знаю как вы будете это использовать, сейчас глянем

Copy link
Owner

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;
Copy link
Owner

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++);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Этого тоже не понял. id это же значение дерева? Почему оно вдруг увеличивается? и зачем каждый раз писать перед выдачей информации по людям. И это значение не обнуляется, значит если несколько раз попросить выписку по семье, то id будет меняться у тех же записей, а это уж совсем неправильно

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants