示例#1
0
        static void Fight()
        {
            Pantera[] panteras = new Pantera[5];
            T34[]     t34s     = new T34[5];

            int destroyedPanteras = 0;
            int destroyedT34s     = 0;


            for (int i = 0; i < 5; i++)
            {
                panteras[i] = new();
                t34s[i]     = new();
            }

            for (int i = 0; i < 5; i++)
            {
                System.Console.WriteLine();

                Console.Write("Pantera\t\t\tT34\n");

                Console.Write(panteras[i].GetAmmunition() + "\t\t\t"
                              + t34s[i].GetAmmunition() + '\n');

                Console.Write(panteras[i].GetArmor() + "\t\t\t"
                              + t34s[i].GetArmor() + '\n');

                Console.Write(panteras[i].GetManeuverability() + "\t\t\t"
                              + t34s[i].GetManeuverability() + '\n');

                Base winner = panteras[i] * t34s[i];

                if (winner is Pantera)
                {
                    System.Console.Write("\n\t\tPantera WON!");
                    destroyedT34s++;
                }
                else if (winner is T34)
                {
                    System.Console.Write("\n\t\tT34 WON!");
                    destroyedPanteras++;
                }

                System.Console.WriteLine();
            }

            if (destroyedPanteras > destroyedT34s)
            {
                System.Console.WriteLine("\n\n\n\t\tWINNER : T34 WON");
            }
            else if (destroyedPanteras < destroyedT34s)
            {
                System.Console.WriteLine("\n\n\n\t\tWINNER : PANTERAS");
            }
            else
            {
                System.Console.WriteLine("\n\n\n\t\tDRAW");
            }
        }
        public void T34Test()
        {
            T34 t34Test = new T34();

            Assert.AreEqual("Black", t34Test.Color);
            Assert.AreEqual("Ussr", t34Test.CountryOfManufacture);
            Assert.AreEqual(56, t34Test.MaxSpeed);
            Assert.AreEqual(400, t34Test.Armor);
            Assert.AreEqual(4, t34Test.CabinCrew);
        }
示例#3
0
        static void Main(string[] args)
        {
            var rnd = new Random();

            Tank[] p = new Tank[3];
            T34[]  t = new T34[3];
            for (int i = 0; i < 3; i++)
            {
                p[i] = new Tank();
            }
            for (int i = 0; i < p.Length; i++)
            {
                t[i] = new T34(rnd.Next(5, 10), rnd.Next(80, 110), rnd.Next(1, 100), rnd.Next(1, 10), rnd.Next(1, 10), "T34");
            }
            Pantera[] pantera = new Pantera[3];
            for (int i = 0; i < p.Length; i++)
            {
                pantera[i] = new Pantera(rnd.Next(5, 10), rnd.Next(80, 110), rnd.Next(1, 100), rnd.Next(1, 10), rnd.Next(1, 10), "pantera");
            }

            for (int i = 0; i < 3; i++)
            {
                //Console.WriteLine("До боя:");
                //t[i].Print();
                //pantera[i].Print();
                //Console.WriteLine("ПослЕ боя:");
                //t[i].Print();
                //pantera[i].Print();
                Tank.Winner(t[i], pantera[i]);
                p[i] = t[i] * pantera[i];
                Console.WriteLine("Победил:");
                p[i].Print();
                if (p[i] == p[2])
                {
                    if (p[0].Name == p[1].Name || p[0].Name == p[2].Name)
                    {
                        Console.WriteLine("Победила армия " + p[0].Name);
                    }
                    else
                    {
                        Console.WriteLine("Победила армия " + p[1].Name);
                    }
                }
                Console.WriteLine();
            }
        }
示例#4
0
        static void Main(string[] args)
        {
            Random        rnd       = new Random();
            List <string> Wins      = new List <string>();
            int           warresult = 0;
            bool          result;

            for (int i = 1; i < 6; i++)
            {
                T34 t1     = new T34 {
                };
                Pantera t2 = new Pantera {
                };
                result = t1 ^ t2;

                if (result)
                {
                    Wins.Add(t1.model);
                    warresult++;
                }
                else
                {
                    Wins.Add(t2.model);
                }
            }

            Wins.Sort();
            foreach (string i in Wins)
            {
                Console.WriteLine(i);
            }
            Console.WriteLine();
            if (warresult >= 3)
            {
                Console.WriteLine($"First tank win in war");
            }
            else
            {
                Console.WriteLine($"Second tank win in war");
            }
        }
示例#5
0
 static bool Do34(T34 t) {
   Nullable<T34> n = new Nullable<T34>(t);
   return Ensure(n.HasValue && n.Value == t);
 }