Exemplo n.º 1
0
    public static void Main()
    {
        IKing  king  = SetupKing();
        string input = Console.ReadLine();

        while (input != "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.Die();
            }

            input = Console.ReadLine();
        }
    }
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.Die();
                }
            }
        }
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.GetAttacket();
            }
            else if (command == "Kill")
            {
                string       name        = tokens[1];
                ISubordinate subordinate = king.Subordinates.First(n => n.Name == name);
                subordinate.Die();
            }
        }
    }
        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.Die();
                }
            }
        }