-
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
Open
slansaf
wants to merge
13
commits into
Liberate520:master
Choose a base branch
from
slansaf:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
31bc8eb
Создана база семейного древа.
slansaf 8121c7f
Added all files
slansaf b1e5714
Добавлены все методы в Human и FamilyTree как у преподавателя
slansaf f792834
Создан интерфейс Writable и класс FileHandler
slansaf 06cbac0
Забыл имплиментироваить интерфейс Serializable класам
slansaf 1a64a82
Реализован интерфейс Iterable, cозданы методы сортировки, создана пак…
slansaf d0f8473
класс сделан параметирзированным
slansaf a38305d
В проекте реализована архитектура MVP
slansaf 0744e18
Создано основное меню, команды расскиданы по классам
slansaf 0d7802e
Добавлен класс MainMenu, Servise
slansaf 9fcb9ee
реализован метод добавления родителей и детей
slansaf 6eeda45
отредактирован метод добавления человека
slansaf d4812e8
Изменен метод добавлния человека, дополнен метод установления родства…
slansaf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package ru.gb.family_tree; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class FamilyTree { | ||
private List<Human> humanList; | ||
|
||
public FamilyTree() { | ||
humanList = new ArrayList<>(); | ||
} | ||
|
||
public void addHuman(Human human){ | ||
humanList.add(human); | ||
} | ||
|
||
public Human findByName(String nameHuman){ | ||
for(Human human: humanList){ | ||
if(human.getName().equalsIgnoreCase(nameHuman)){ | ||
return human; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
StringBuilder stringBuilder = new StringBuilder(); | ||
stringBuilder.append("Список людей:\n"); | ||
for (Human human : humanList) { | ||
stringBuilder.append(human); | ||
stringBuilder.append("\n"); | ||
} | ||
return stringBuilder.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package ru.gb.family_tree; | ||
|
||
public enum Gender { | ||
Male, Female | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package ru.gb.family_tree; | ||
|
||
import java.time.LocalDate; | ||
import java.util.List; | ||
|
||
public class Human { | ||
private String name; | ||
private LocalDate dob, dod; | ||
private List<Human> children; | ||
private Human father, mather; | ||
private Gender gender; | ||
|
||
public Human(String name, Gender gender, LocalDate dob) { | ||
this.name = name; | ||
this.gender = gender; | ||
this.dob = dob; | ||
} | ||
|
||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Почему вдруг именно такая дата? Ошибка писать такие даты, потом непонятно откуда берутся артефакты) |
||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public Gender getGender() { | ||
return gender; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Name: " + name + ", Gender: " + gender + ", Birthday: " + dob; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package ru.gb.family_tree; | ||
|
||
import java.time.LocalDate; | ||
|
||
public class Main { | ||
public static void main(String[] args) { | ||
FamilyTree familyTree = new FamilyTree(); | ||
|
||
Human human1 = new Human("Oleg", Gender.Male, LocalDate.of(1985, 12, 12)); | ||
Human human2 = new Human("Olga", Gender.Female, LocalDate.of(1984, 6, 18)); | ||
Human human3 = new Human("Ruslan", Gender.Male, LocalDate.of(2006, 10, 10)); | ||
Human human4 = new Human("Lena", Gender.Female, LocalDate.of(2016, 5, 4)); | ||
Human human5 = new Human("Polina", Gender.Female); | ||
|
||
familyTree.addHuman(human1); | ||
familyTree.addHuman(human2); | ||
familyTree.addHuman(human3); | ||
familyTree.addHuman(human4); | ||
familyTree.addHuman(human5); | ||
|
||
System.out.println(familyTree); | ||
|
||
System.out.println(familyTree.findByName("olga").getName()); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Ни в какой момент не изменяется состояние этих полей