Пример #1
0
        static void Main(string[] args)
        {
            OgreAlien o1 = new OgreAlien(100, "Ogre 1");
            OgreAlien o2 = new OgreAlien(100, "Ogre 2");

            SnakeAlien s1 = new SnakeAlien(100, "Snake 1");
            SnakeAlien s2 = new SnakeAlien(100, "Snake 2");

            MMAlien mm1 = new MMAlien(100, "MM 1");
            MMAlien mm2 = new MMAlien(100, "MM 2");

            AlienPack group = new AlienPack(6);

            group.AddAlien(o1, 0);
            group.AddAlien(o2, 1);
            group.AddAlien(s1, 2);
            group.AddAlien(s2, 3);
            group.AddAlien(mm1, 4);
            group.AddAlien(mm2, 5);

            Console.WriteLine("Alien group damage: " + group.CalculateDamage());
        }
Пример #2
0
        public int CalculateDamage()
        {
            int damage = 0;

            foreach (Alien a in aliens)
            {
                if (a is MMAlien)
                {
                    damage += MMAlien.GetDamage();
                }
                else if (a is OgreAlien)
                {
                    damage += OgreAlien.GetDamage();
                }
                else if (a is SnakeAlien)
                {
                    damage += SnakeAlien.GetDamage();
                }
            }

            return(damage);
        }