示例#1
0
 public static void Menu(this FoodCollection <string> menu)
 {
     Console.WriteLine("OUR MENU");
     for (int i = 0; i < menu.FoodAmount(); i++)
     {
         Console.WriteLine(menu.Meals[i]);
     }
 }
示例#2
0
        // Using "Clean code" rule
        // Исполнение лишь одной операции в функции
        private FoodCollection <string> addFoodToRation()
        {
            FoodCollection <string> ration = new   FoodCollection <string>();

            ration.AddDish(Racion.bread.ToString());
            ration.AddDish((Racion.salt.ToString()));
            ration.AddDish(Racion.water.ToString());
            return(ration);
        }
示例#3
0
        public void Ration()
        {
            FoodCollection <string> ration = addFoodToRation();
            Action <int, string[]>  action = delegate(int foodAmount, string [] meals)
            {
                for (int i = 0; i < foodAmount; i++)
                {
                    Console.WriteLine(meals[i]);
                }
            };

            action(ration.FoodAmount(), ration.Meals);
        }