예제 #1
0
        static void Main()
        {
            Handler handler = new Handler();

            string kingName = Console.ReadLine();
            string guards   = Console.ReadLine();
            string footmen  = Console.ReadLine();

            IKing king = new King(kingName);

            king.GotAttacked      += handler.On_King_GotAttacked;
            king.GetSomeoneKilled += handler.On_King_GetSomeOneKilled;
            king.RegisterGuard(guards);
            king.RegisterFootman(footmen);

            string[] input = Console.ReadLine().Split();
            while (input[0] != "End")
            {
                if (input[0].ToLower() == "attack")
                {
                    king.GetAttacked();
                }
                else if (input[0].ToLower() == "kill")
                {
                    string name = input[1];
                    king.Murder(name);
                }
                input = Console.ReadLine().Split();
            }
        }
예제 #2
0
    static void Main()
    {
        King king = SetupKing();

        string input = Console.ReadLine();

        while (input != "End")
        {
            string[] commandTokens = input.Split(' ', StringSplitOptions.RemoveEmptyEntries);

            switch (commandTokens[0])
            {
            case "Attack":
                king.GetAttacked();
                break;

            case "Kill":
                Subject subject = king.Subjects.First(s => s.Name == commandTokens[1]);
                subject.Die();
                king.KillSubject(subject);
                break;
            }

            input = Console.ReadLine();
        }
    }