Exemplo n.º 1
0
        public void HitTest()
        {
            Ship testShip = new Ship(ShipName.AircraftCarrier);

            testShip.Hit();
            testShip.Hit();

            Assert.IsTrue(testShip.Hits == 2);
        }
Exemplo n.º 2
0
        public void IsDestroyedTest()
        {
            Ship testShip = new Ship(ShipName.AircraftCarrier);

            for (int i = 0; i < 5; i++)
            {
                testShip.Hit();
            }
            bool expected = true;
            bool actual   = testShip.IsDestroyed;

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 3
0
 /*
  * Summary: Shoot allows a tile to be shot at, and if the tile has been hit before
  * it will give an error
  */
 internal void Shoot()
 {
     if ((false == Shot))
     {
         Shot = true;
         if (_ship != null)
         {
             _ship.Hit();
         }
     }
     else
     {
         throw new ApplicationException("You have already shot this square");
     }
 }