Beispiel #1
0
        public int CalculateIncome()
        {
            var orderedPowerStations = PowerStations.OrderByDescending(p => p.Power);
            List <PowerStation> stationsThatCanBePowered = new List <PowerStation>();

            foreach (var powerStation in PowerStations)
            {
                if (CanPower(powerStation))
                {
                    stationsThatCanBePowered.Add(powerStation);
                }
            }
            return(stationsThatCanBePowered.Sum(p => p.Power));
        }
Beispiel #2
0
 public int GetBiggestPowerStation()
 {
     return(PowerStations.OrderByDescending(p => p.Value).FirstOrDefault()?.Value ?? 0);
 }