示例#1
0
        static void Main(string[] args)
        {
            Grid grid = new Grid();

            //int userChoice = 0;

            //Greet the user
            grid.Greet();

            //build 5 ships
            Ship ship1 = new Ship(ShipType.Submarine);
            Ship ship2 = new Ship(ShipType.Minesweeper);
            Ship ship3 = new Ship(ShipType.Cruiser);
            Ship ship4 = new Ship(ShipType.Carrier);
            Ship ship5 = new Ship(ShipType.Battleship);

            //place the ships in ocean
            grid.PlaceShip(ship1);
            grid.PlaceShip(ship2);
            grid.PlaceShip(ship3);
            grid.PlaceShip(ship4);
            grid.PlaceShip(ship5);

            //Console.WriteLine("Enter 1 to play by yourself\nEnter 2 for computer to play");
            //userChoice = int.Parse(Console.ReadLine());

            //switch (userChoice)
            //{
            //    case 1:
            grid.PlayGame();
            // case 2:
        }
示例#2
0
        static void Main(string[] args)
        {
            Grid grid = new Grid();

            Ship submarine   = new Ship(Ship.ShipType.Submarine);
            Ship carrier     = new Ship(Ship.ShipType.Carrier);
            Ship cruiser     = new Ship(Ship.ShipType.Cruiser);
            Ship minesweeper = new Ship(Ship.ShipType.Minesweeper);
            Ship battleship  = new Ship(Ship.ShipType.Battleship);

            grid.PlaceShip(submarine, Grid.PlaceShipDirection.Vertical, 9, 2);
            grid.PlaceShip(carrier, Grid.PlaceShipDirection.Vertical, 7, 3);
            grid.PlaceShip(cruiser, Grid.PlaceShipDirection.Horizontal, 4, 1);
            grid.PlaceShip(minesweeper, Grid.PlaceShipDirection.Horizontal, 6, 2);
            grid.PlaceShip(battleship, Grid.PlaceShipDirection.Vertical, 1, 1);
        }