Exemplo n.º 1
0
    public static void Main()
    {
        var inhabitans = new List <IInhabitant>();
        var factory    = new InhabitantFactory();

        string input;

        while ((input = Console.ReadLine()) != "End")
        {
            inhabitans.Add(factory.CreateInhabitant(input.Split().ToArray()));
        }

        var idPart = Console.ReadLine();

        foreach (var inhabitant in inhabitans.Where(i => i.Id.EndsWith(idPart)))
        {
            Console.WriteLine(inhabitant.Id);
        }
    }
Exemplo n.º 2
0
        public void Run()
        {
            string input = Console.ReadLine();

            var inhabitants = new List <IInhabitant>();

            while (input != "End")
            {
                IInhabitant inhabitant = inhabitantFactory.CreateInhabitant(input);

                inhabitants.Add(inhabitant);

                input = Console.ReadLine();
            }

            input = Console.ReadLine();
            foreach (var item in inhabitants)
            {
                if (item.Id.EndsWith($"{input}"))
                {
                    Console.WriteLine(item.Id);
                }
            }
        }