Exemplo n.º 1
0
        static void Main(string[] args)
        {
            try
            {
                Invoker      client   = new Invoker();
                InputNewUser userData = new InputNewUser();
                DataCreator  dataInfo = new DataCreator();
                userData.OutputNamesakes += WriteAndOutputNamesakes;
                bool escapeCondition = true;
                client.SetCommand(new InformationOnCommand(dataInfo, userData));
                while (escapeCondition)
                {
                    Console.WriteLine("Select an action (enter the action number in the console) :\n1) Enter new user \n2)Calculate the average age of users \n3)find the senior user \n4)find the most popular woman name");
                    string stringKey = Console.ReadLine();
                    switch (stringKey)
                    {
                    case "1":
                        userData.AddUsers();
                        break;

                    case "2":
                        client.CalculateAverageAge();
                        break;

                    case "3":
                        client.FindOldestUser();
                        break;

                    case "4":
                        client.FindPopularWomanName();
                        break;
                    }
                }
            }
            catch (FormatException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemplo n.º 2
0
 public InformationOnCommand(DataCreator dataCreater, InputNewUser inputNewUser)
 {
     dataInfo = dataCreater;
     input    = inputNewUser;
 }