Beispiel #1
0
        public void IsShipDirectionValid_ValidPointValidSizeLeftDirection()
        {
            Point         point         = new Point(9, 1);
            int           shipSize      = 5;
            ShipDirection shipDirection = ShipDirection.Left;

            Assert.IsTrue(GridValidator.IsShipDirectionValid(shipSize, point, shipDirection));
        }
Beispiel #2
0
        public void IsShipDirectionValid_ValidPointValidSizeDownDirection()
        {
            Point         point         = new Point(9, 6);
            int           shipSize      = 4;
            ShipDirection shipDirection = ShipDirection.Down;

            Assert.IsTrue(GridValidator.IsShipDirectionValid(shipSize, point, shipDirection));
        }
Beispiel #3
0
        public void IsShipDirectionValid_ValidPointSizeDirection()
        {
            Point         point         = new Point(4, 6);
            int           shipSize      = 5;
            ShipDirection shipDirection = ShipDirection.Right;

            Assert.IsTrue(GridValidator.IsShipDirectionValid(shipSize, point, shipDirection));
        }
Beispiel #4
0
        public void IsShipDirectionValid_ValidPointValidSizeRightDirection()
        {
            Point         point         = new Point(9, 6);
            int           shipSize      = 4;
            ShipDirection shipDirection = ShipDirection.Right;

            Assert.IsFalse(GridValidator.IsShipDirectionValid(shipSize, point, shipDirection));
        }
Beispiel #5
0
 private void ConstructShip(Point point, ShipDirection direction)
 {
     if (GridValidator.IsShipDirectionValid(Size, point, direction))
     {
         FillPoints(point, direction);
     }
     else
     {
         int randTrial = rand.Next(1, 2) % 2;
         direction = randTrial == 0 ? GetRandomDirection() : direction;
         point     = randTrial == 1 ? new Point(rand.Next(1, Constants.GridLength), rand.Next(1, Constants.GridLength)) : point;
         ConstructShip(point, direction);
     }
 }