Exemplo n.º 1
0
        public void Run()
        {
            string input = "";

            while ((input = Console.ReadLine()) != "End")
            {
                string[] tokens = input.Split().ToArray();

                string command = tokens[0];
                string name    = tokens[1];

                switch (command)
                {
                case "Attack":
                    king.GetAttacked();
                    break;

                case "Kill":
                    ISubordinate subordinate = king.Subordinates.First(s => s.Name == name);

                    subordinate.TakeDamage();

                    break;

                default:
                    throw new ArgumentException("Invalid Command !");
                }
            }
        }
Exemplo n.º 2
0
        public void Run()
        {
            string line;

            while ((line = Console.ReadLine()) != "End")
            {
                string[] tokens  = line.Split();
                string   command = tokens[0];

                if (command == "Attack")
                {
                    king.ReceiveAttack();
                }
                else
                {
                    string       subordinateName = tokens[1];
                    ISubordinate subordinate     = king.Subordinates.First(s => s.Name == subordinateName);
                    subordinate.TakeDamage();
                }
            }
        }
Exemplo n.º 3
0
        public void Run()
        {
            string input;

            while ((input = Console.ReadLine()) != "End")
            {
                string[] tokens  = input.Split();
                string   command = tokens[0];
                if (command == "Attack")
                {
                    king.GetAttacked();
                }
                else if (command == "Kill")
                {
                    string       subordinateName = tokens[1];
                    ISubordinate subordinate     = king.Subordinates.First(s => s.Name == subordinateName);

                    subordinate.TakeDamage();
                }
            }
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            IKing king = KingSetter();

            string input = String.Empty;

            while ((input = Console.ReadLine()) != "End")
            {
                string[] tokens = input.Split();
                string   cmd    = tokens[0];

                if (cmd == "Attack")
                {
                    king.BeingAttacked();
                }
                else if (cmd == "Kill")
                {
                    string       name = tokens[1];
                    ISubordinate unit = king.Army.First(u => u.Name == name);
                    unit.TakeDamage();
                }
            }
        }