コード例 #1
0
        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--]);
            }
        }
コード例 #2
0
        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();
        }