private List<Coordinate> BuildCoordinatesList(Ship ship, int yAxis, int xAxis)
        {
            var coordinates = new List<Coordinate>();

            if (ship.Orientation == Enums.Orientation.Horizontal)
            {
                for (var i = 0; i < ship.NumberOfSquares; i++)
                {
                    coordinates.Add(new Coordinate { XAxis = xAxis + i, YAxis = yAxis });
                }
            }
            else
            {
                for (var i = 0; i < ship.NumberOfSquares; i++)
                {
                    coordinates.Add(new Coordinate { XAxis = xAxis, YAxis = yAxis + i });
                }
            }

            return coordinates;
        }
Esempio n. 2
0
 private Ship GenerateShip(Ship ship)
 {
     return(GridValidator.IsShipValid(ships, ship) ? ship : GenerateShip(new Ship(ship.Size)));
 }