static void Main(string[] args)
        {
            var    soldiers = new List <Soldier>();
            string command;

            while ((command = Console.ReadLine()) != "End")
            {
                try
                {
                    var     tokens     = command.Split();
                    Soldier newSoldier = SoldierFactory.FindSoldier(tokens, soldiers);
                    soldiers.Add(newSoldier);
                    Console.WriteLine(newSoldier);
                }
                catch (ArgumentException) { }
            }
        }
Exemple #2
0
        public void Run()
        {
            string[] input = Console.ReadLine().Split();

            while (input[0] != "End")
            {
                try
                {
                    soldiers.Add(SoldierFactory.ProduceSoldier(input));
                }
                catch (Exception)
                {
                }

                input = Console.ReadLine().Split();
            }
            foreach (var soldier in soldiers)
            {
                Console.WriteLine(soldier.ToString());
            }
        }
        static void Main()
        {
            var soldiers = new List <ISoldier>();

            var input = Console.ReadLine();

            while (!input.Equals("End"))
            {
                try
                {
                    soldiers.Add(SoldierFactory.Soldier(input));
                }
                catch (Exception)
                {
                }

                input = Console.ReadLine();
            }

            foreach (var soldier in soldiers)
            {
                Console.Write(soldier);
            }
        }