Пример #1
0
        static void Main(string[] args)
        {
            string            mainPersonInput   = Console.ReadLine();
            FamilyTreeBuilder familyTreeBuilder = new FamilyTreeBuilder(mainPersonInput);

            string command;

            while ((command = Console.ReadLine()) != "End")
            {
                ParseInput(command, familyTreeBuilder);
            }

            Console.WriteLine(familyTreeBuilder.Build());
        }
Пример #2
0
        static void Main(string[] args)
        {
            string            mainPersonInput   = Console.ReadLine();
            FamilyTreeBuilder familyTreeBuilder = new FamilyTreeBuilder(mainPersonInput);

            string command;

            while ((command = Console.ReadLine()) != "End")
            {
                ParseInput(familyTreeBuilder, command);
            }

            PrintMainPersonTree(familyTreeBuilder.MainPerson);
        }
Пример #3
0
 private static void ParseInput(string command, FamilyTreeBuilder familyTreeBuilder)
 {
     string[] tokens = command.Split(" - ");
     if (tokens.Length > 1)
     {
         string parentInput = tokens[0];
         string childInput  = tokens[1];
         familyTreeBuilder.SetParentChildRelation(parentInput, childInput);
     }
     else
     {
         tokens = tokens[0].Split();
         string name     = $"{tokens[0]} {tokens[1]}";
         string birthday = tokens[2];
         familyTreeBuilder.SetFullInfo(name, birthday);
     }
 }