public void DistributeMoney(decimal money) { var values = Divider.Divide(money, _components.Count); int ctr = values.Length - 1; foreach (var component in _components) { component.ReceiveMoney(values[ctr--]); } }
static void Main(string[] args) { var children = new Children(); children.Add(new Belle()); children.Add(new Letty()); IPerson[] persons = { new Francis(), new Isa(), children }; const int payout = 10000; var values = Divider.Divide(payout, persons.Length); var ctr = values.Length - 1; foreach (var person in persons) { person.ReceiveMoney(values[ctr--]); } PrintMoney(persons); Console.ReadLine(); }