Exemplo n.º 1
0
        static void Main(string[] args)
        {
            personStorage = new PersonStorage();
            LoadPeople();

            FamilyGraph = new FamilyGraph(personStorage);
            LoadRelations();

            relations = new BaseRelationships(FamilyGraph);
            using (var reader = new StreamReader(Path.Combine("InputFiles", "Testcase.txt")))
            {
                while (!reader.EndOfStream)
                {
                    var input  = reader.ReadLine();
                    var values = input.Split(" ").Select(m => m.Trim()).ToList();
                    // Console.WriteLine($"TestCase: {input}");
                    if (values[0] == "ADD_CHILD")
                    {
                        AddChild(values);
                    }
                    else if (values[0] == "GET_RELATIONSHIP")
                    {
                        try
                        {
                            GetRelation(values);
                        }
                        catch (Exception) { }
                    }
                    Console.WriteLine();
                }
            }
            //Console.ReadKey();
        }
Exemplo n.º 2
0
        public void SetUp()
        {
            IPersonStorage storage = new PersonStorage();

            george                = storage.AddPerson("George", Gender.Male);
            mary                  = storage.AddPerson("Mary", Gender.Female);
            bob                   = storage.AddPerson("Bob", Gender.Male);
            sally                 = storage.AddPerson("Sally", Gender.Female);
            dave                  = storage.AddPerson("Dave", Gender.Male);
            davesMaternalUncle    = storage.AddPerson("Hulk", Gender.Male);
            davesPaternalAunt     = storage.AddPerson("Aunt", Gender.Female);
            davesMaternalGrandDad = storage.AddPerson("Thor", Gender.Male);
            davesMaternalGrandMom = storage.AddPerson("Wonder", Gender.Female);
            davesPaternalGrandDad = storage.AddPerson("Thor1", Gender.Male);
            davesPaternalGrandMom = storage.AddPerson("Wonder1", Gender.Female);

            amy          = storage.AddPerson("Amy", Gender.Female);
            bamy         = storage.AddPerson("Bamy", Gender.Female);
            miller       = storage.AddPerson("Miller", Gender.Male);
            amysBrother  = storage.AddPerson("BigB", Gender.Male);
            amysBrother1 = storage.AddPerson("ABig", Gender.Male);
            amysMom      = storage.AddPerson("Miley", Gender.Female);
            amysDad      = storage.AddPerson("Brad", Gender.Male);

            FamilyGraph familyGraph = new FamilyGraph(storage);

            //Daves Family
            familyGraph.AddRelationship("Thor", "Mary", "Parent");
            familyGraph.AddRelationship("Wonder", "Mary", "Parent");
            familyGraph.AddRelationship("Thor", "Hulk", "Parent");
            familyGraph.AddRelationship("Wonder", "Hulk", "Parent");

            familyGraph.AddRelationship("Thor1", "George", "Parent");
            familyGraph.AddRelationship("Wonder1", "George", "Parent");
            familyGraph.AddRelationship("Thor1", "Aunt", "Parent");
            familyGraph.AddRelationship("Wonder1", "Aunt", "Parent");

            familyGraph.AddRelationship("George", "Bob", "Parent");
            familyGraph.AddRelationship("Mary", "Bob", "Parent");
            familyGraph.AddRelationship("George", "Dave", "Parent");
            familyGraph.AddRelationship("Mary", "Dave", "Parent");
            familyGraph.AddRelationship("George", "Sally", "Parent");
            familyGraph.AddRelationship("Mary", "Sally", "Parent");


            //Spouse
            familyGraph.AddRelationship("Dave", "Amy", "Spouse");

            //Amy's Family
            familyGraph.AddRelationship("Brad", "Miller", "Parent");
            familyGraph.AddRelationship("Miley", "Miller", "Parent");
            familyGraph.AddRelationship("Brad", "ABig", "Parent");
            familyGraph.AddRelationship("Miley", "ABig", "Parent");
            familyGraph.AddRelationship("Brad", "BigB", "Parent");
            familyGraph.AddRelationship("Miley", "BigB", "Parent");
            familyGraph.AddRelationship("Brad", "Amy", "Parent");
            familyGraph.AddRelationship("Miley", "Amy", "Parent");
            familyGraph.AddRelationship("Brad", "Bamy", "Parent");
            familyGraph.AddRelationship("Miley", "Bamy", "Parent");

            relationships = new BaseRelationships(familyGraph);
        }