コード例 #1
0
ファイル: Game.cs プロジェクト: katarzynastozek/battleShip
        private List <Ship> CreateFleet()
        {
            FleetConfig fleetConfig = new FleetConfig();

            fleetConfig.OneMastShipCount   = _userInterface.GetOneMastShipsAmount();
            fleetConfig.TwoMastShipCount   = _userInterface.GetTwoMastShipsAmount();
            fleetConfig.ThreeMastShipCount = _userInterface.GetThreeMastShipsAmount();

            ShipsFactory shipFactory = new ShipsFactory();

            return(shipFactory.GetFleet(fleetConfig));
        }
コード例 #2
0
        public List <Ship> GetFleet(FleetConfig config)
        {
            List <Ship> fleet = new List <Ship>();

            for (int i = 0; i < config.ThreeMastShipCount; i++)
            {
                fleet.Add(new ThreeMastShip());
            }

            for (byte i = 0; i < config.TwoMastShipCount; i++)
            {
                fleet.Add(new TwoMastShip());
            }

            for (byte i = 0; i < config.OneMastShipCount; i++)
            {
                fleet.Add(new OneMastShip());
            }

            return(fleet);
        }