public override void Execute(Dictionary <string, object> data) { var list = new List <int>(); var sum = 0; foreach (int moduleWeight in (IEnumerable <int>)data[_moduleWeightsKey]) { var fuel = MassFuelCalculator.Calculate(moduleWeight); list.Add(fuel); sum += fuel; } data.Add(DataKey, list.ToArray()); data.Add(DataSumKey, sum); }
public override void Execute(Dictionary <string, object> data) { var list = new List <int>(); var sum = 0; foreach (int fuelWeight in (IEnumerable <int>)data[ModuleFuelCalculator.DataKey]) { var moduleSum = 0; var reqFuel = fuelWeight; while (reqFuel > 0) { reqFuel = Math.Max(0, MassFuelCalculator.Calculate(reqFuel)); moduleSum += reqFuel; } list.Add(moduleSum); sum += moduleSum; } data.Add(DataKey, list.ToArray()); data.Add(DataSumKey, sum); }