static public void Main(string[] args)
b.PlaceShip(s, 4, 5, true);
b.PlaceShip(s, 2, 3, false);
b.PlaceShip(s, 8, 8, true);
Console.WriteLine("2,3 = " + b.Shoot(2, 3));
Console.WriteLine("4,5 = " + b.Shoot(4, 5));
Console.WriteLine("6,7 = " + b.Shoot(6, 7));
Console.WriteLine("8,9 = " + b.Shoot(8, 9));
Console.WriteLine("3,4 = " + b.Shoot(3, 4));
Console.WriteLine("3,3 = " + b.Shoot(3, 3));
public bool Sunk = false;
if (_size == 0) return HitResult.Miss;
else return HitResult.Hit;
Ship[,] _grid = new Ship[10, 10];
public Board(Player player)
for (int x = 0; x < 10; x++)
for (int y = 0; y < 10; y++)
_grid[x, y] = new Ship(0);
public void PlaceShip(Ship ship, int StartX, int StartY, bool Vertical)
if (ship.Size == 0) _grid[StartX, StartY] = ship;
for (int y = 0; y < ship.Size; y++)
_grid[StartX, StartY + y] = ship;
for (int x = 0; x < ship.Size; x++)
_grid[StartX + x, StartY] = ship;
public HitResult Shoot(int X, int Y)
return _grid[X, Y].Hit();
for (int y = 0; y < 10; y++)
for (int x = 0; x < 10; x++)
if (_grid[x, y].Size == 0) Console.Write(".");
else if (_grid[x, y].Sunk) Console.Write("-");