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)); }
public int GetBiggestPowerStation() { return(PowerStations.OrderByDescending(p => p.Value).FirstOrDefault()?.Value ?? 0); }