示例#1
0
        // Dependency Inversion Principle:
        // Reducing dependencies using an interface class creating greater stability.
        protected bool StartNextDay(IDay day)
        {
            if (!conditions.Any())
            {
                return(false);
            }

            var weatherOnDay = conditions.Dequeue();

            if (PositiveResult)
            {
                day.CheckWeather(weatherOnDay);
                day.BuyIngredients();
                var product = day.CreateProduct();
                if (product == null)
                {
                    PositiveResult = false;
                    return(true);
                }
                day.SellProduct(product, weatherOnDay);
            }
            return(true);
        }