Example #1
0
        public bool War(Armada otherArmy)
        {
            int myArmyI    = 0;
            int otherArmyI = 0;

            while (this.Ships.Count - 1 != myArmyI && otherArmy.Ships.Count - 1 != otherArmyI)
            {
                if (this.Ships[myArmyI].BattleUntilDeath(otherArmy.Ships[otherArmyI]))
                {
                    Console.WriteLine();
                    otherArmyI++;
                }
                else
                {
                    Console.WriteLine();
                    myArmyI++;
                }
            }
            if (this.Ships.Count - 1 == myArmyI)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Example #2
0
        public static void Main()
        {
            Armada army1 = new Armada(10);
            Armada army2 = new Armada(10);

            if (army1.War(army2))
            {
                Console.WriteLine("army1 has won");
            }
            else
            {
                Console.WriteLine("army2 has won");
            }
        }