-
Notifications
You must be signed in to change notification settings - Fork 69
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
Создана база семейного древа. #16
base: master
Are you sure you want to change the base?
Conversation
src/ru/gb/family_tree/Human.java
Outdated
} | ||
|
||
public Human(String name, Gender gender) { | ||
this(name, gender, LocalDate.of(1900,12,12)); |
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.
Почему вдруг именно такая дата? Ошибка писать такие даты, потом непонятно откуда берутся артефакты)
src/ru/gb/family_tree/Human.java
Outdated
private List<Human> children; | ||
private Human father, mather; |
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.
Ни в какой момент не изменяется состояние этих полей
return false; | ||
} | ||
|
||
public boolean remuve(long humansId){ |
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.
опечатка в названии
getHumanInfo(); | ||
} | ||
|
||
public void addChildren(int nameParent, int nameChild) { |
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.
странно, что переменная называется nameParent и при этом имеет тип int
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.
Хотел по имени добавлять родителей, потом вспомнил, имена могут повторяться.
import java.util.List; | ||
|
||
public class Service { | ||
private FamilyTree familyTree; |
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
|
||
public class Service { | ||
private FamilyTree familyTree; | ||
private String filePath = "src/ru/gb/family_tree/model/save/tree.txt"; |
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 void addChildren(int nameParent, int nameChild){ | ||
familyTree.getById(nameParent).addChild(familyTree.getById(nameChild)); | ||
} |
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 String getHumanInfo(){ | ||
String answer = familyTree.getInfo(); | ||
return answer; | ||
} |
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 static FamilyTree load(String filePath){ | ||
Writable writable = new FileHandler(); | ||
return (FamilyTree) writable.read(filePath); | ||
} | ||
|
||
private static void save(FamilyTree familyTree, String filePath){ | ||
Writable writable = new FileHandler(); | ||
writable.save(familyTree, filePath); | ||
} |
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.
Убрать статику. Сделать обычным методом. Writable сделать полем. Убрать нарушение 5 принципа. Зависимость должна быть от абстракции
…, исправлен метод записи и считывания данных
No description provided.