private void RemoveGreatHouse()
        {
            var houseToDowngradeToHouse = this.Houses
                .Where(h => h.ControlledCities.Count() < MinCitiesRequiredToReamainGreat && h is GreatHouse).ToList();

            foreach (var house in houseToDowngradeToHouse)
            {
                var houseToAdd = new House(house.Name, house.TreasuryAmount);
                foreach (var city in house.ControlledCities)
                {
                    houseToAdd.AddCityToHouse(city);
                }

                this.Houses.Remove(house);
                this.Houses.Add(houseToAdd);
            }
        }
Exemplo n.º 2
0
        public void UpdateHouse()
        {
            var housesToRemove = new List<IHouse>();
            var housesToAdd = new List<IHouse>();

            foreach (var house in this.Houses)
            {
                if (house is House && house.ControlledCities.Count() >= 10)
                {
                    var greatHouse = new GreatHouse(house.Name, house.TreasuryAmount);

                    foreach (var city in house.ControlledCities)
                    {
                        greatHouse.AddCityToHouse(city);
                    }

                    housesToRemove.Add(house);
                    housesToAdd.Add(greatHouse);
                }

                if (house is GreatHouse && house.ControlledCities.Count() < 5)
                {
                    var normalHouse = new House(house.Name, house.TreasuryAmount);

                    foreach (var city in house.ControlledCities)
                    {
                        normalHouse.AddCityToHouse(city);
                    }

                    housesToRemove.Add(house);
                    housesToAdd.Add(normalHouse);
                }
            }

            foreach (var house in housesToRemove)
            {
                this.Houses.Remove(house);
            }

            foreach (var house in housesToAdd)
            {
                this.Houses.Add(house);
            }
        }
Exemplo n.º 3
0
        public Employee(
            uint    monthlySalary,
            double  hraPercent,
            House   currentProperty)
        {
            if (currentProperty == null)
            {
                throw new ArgumentNullException("currentProperty");
            }

            if (hraPercent <= 0 || 100 <= hraPercent)
            {
                throw new ArgumentException("hraPercent", "hraPercent should between between 0 and 100.");
            }

            if (monthlySalary <= MINIMUM_MONTHLY_SALARY)
            {
                throw new ArgumentException("monthlySalary", "monthlySalary is below minimum salary.");
            }

            this.monthlyBasicSalary        = monthlySalary;
            this.houseRentAllowancePercent = hraPercent;
            this.currentProperty           = currentProperty;
        }