Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- public class Main {
- public static void main(String[] args) throws IOException {
- BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
- String searchedID = reader.readLine();
- FamilyTree family = new FamilyTree();
- reader.lines().takeWhile(line -> !"End".equals(line)).forEach(line -> {
- if (line.contains(" - ")){
- String[] token = line.split(" - ");
- String parentID = token[0];
- String childID = token[1];
- family.addIDs(parentID, childID);
- }else {
- String[] token = line.split("\\s+");
- String name = token[0] + " " + token[1];
- String birthDate = token[2];
- family.addPerson(name, birthDate);
- }
- });
- family.buildRelations();
- Person searchedPerson = family.getPerson(searchedID);
- System.out.println(family.getFamilyTreeFor(searchedPerson));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment