예제 #1
0
        private Ship CreateShip(string input, ICoordinateBoundary cb)
        {
            var coord = cb.CoordinateFromInput(input);
            var pos   = ShipPosition.Horizontal(coord, ShipSize.Destroyer);

            return(new Ship(pos));
        }
예제 #2
0
        private IEnumerable <BattleCoordinate> CalculateCoordinatesWithinBoundary(ICoordinateBoundary boundary)
        {
            var coords = new List <BattleCoordinate>();

            for (int c = 0; c < boundary.ColumnValues.Count(); c++)
            {
                for (int r = 0; r < boundary.RowValues.Count(); r++)
                {
                    coords.Add(new BattleCoordinate(c, r, boundary.ColumnValues.Count(), boundary.RowValues.Count()));
                }
            }
            return(coords);
        }
예제 #3
0
 public TestShotStrategy(ICoordinateBoundary boundary)
 {
     this.boundary = boundary;
 }
예제 #4
0
 public string ToString(ICoordinateBoundary boundary) => boundary.CoordinateToString(this);
예제 #5
0
 public FleetBuilder(ICoordinateBoundary boundary, IRandomProvider random)
 {
     this.coordinates = CalculateCoordinatesWithinBoundary(boundary);
     this.random      = random;
 }
예제 #6
0
 public RandomShotStrategy(ICoordinateBoundary boundary, IRandomProvider random)
 {
     this.boundary = boundary;
     this.random   = random;
 }
 public ConsoleReadShotStrategy(ICoordinateBoundary boundary)
 {
     this.boundary = boundary;
 }