static void Main(string[] args) { var gridReferenceGenerator = new GridReferenceGenerator(new RandomNumberGenerator(1, 10)); var orientationGenerator = new OrientationGenerator(new RandomNumberGenerator(1, 10)); var shipPlacementManager = new ShipPlacementManager(gridReferenceGenerator, orientationGenerator); var game = new Game(shipPlacementManager); var ships = 5; var shipexists = true; while (shipexists) { Console.WriteLine("Input grid reference to Attack - e.g. A1"); var gridReference = Console.ReadLine(); var attackResult = game.Attack(gridReference); Console.WriteLine(attackResult); if (attackResult.Contains("Sunk")) { ships--; } if (ships == 0) { shipexists = false; } } Console.WriteLine("Game Over"); Console.ReadKey(); }
static void Main(string[] args) { Game game = new Game(); Console.WriteLine("Welcome to battleships."); game.PositionShips(); game.TakeTurns(); Console.WriteLine("Game over"); Console.ReadLine(); }