Пример #1
0
        public static void Main(string[] args)
        {
            GoodGuy frodo   = new GoodGuy("Frodo", 1);
            GoodGuy aragorn = new GoodGuy("Aragorn", 20);
            BadGuy  orc     = new BadGuy("Orc", 100);

            frodo.Attack(orc);
            frodo.Attack(orc);
            frodo.Attack(orc);
            aragorn.Attack(orc);

            Console.ReadKey();
        }
Пример #2
0
        public void Attack(BadGuy target)
        {
            Console.WriteLine(_name + " attacks " + target.GetName() + ".");
            target.TakeDamage(_level * 10);

            if (target.IsAlive())
            {
                Console.WriteLine(target.GetName() + " has (" + target.GetHealth() + ") health left.");
            }
            else
            {
                Console.WriteLine(target.GetName() + " is dead!");
            }

            Console.WriteLine();
        }