示例#1
0
        public Board GameSetUp()
        {
            //create board instance for current player
            //create placementRequest
            Board            playerBoard      = new Board();
            PlaceShipRequest placementRequest = new PlaceShipRequest();
            int shipsPlaced = 0;

            while (shipsPlaced < 5)
            {
                //populate ships on board for current player based on their input
                //get ship type
                ShipType ship = ConsoleInput.GetShipType();
                placementRequest.ShipType = ship;

                //get coordinates
                Coordinate shipCoordinates = GetShipCoordinates();
                placementRequest.Coordinate = shipCoordinates;

                //get ship direction
                ShipDirection direction = ConsoleInput.GetShipDirection();
                placementRequest.Direction = direction;

                ShipPlacement response = playerBoard.PlaceShip(placementRequest);
                ConsoleOutput.DisplayShipPlacementResult(response);
                if (response == ShipPlacement.Ok)
                {
                    shipsPlaced++;
                }
            }
            Console.Clear();
            return(playerBoard);
        }