private void DecrementDaysToSell(ICheese cheese) { if (cheese.DaysToSell > 0) { cheese.DaysToSell--; } }
public static Burger CreateMany(ICheese cheese, int number = 1) { return(new Burger("default", cheese) { Number = number }); }
protected PizzaIngredientFactory(IDough dough, ISauce sauce, IClams clams, ICheese cheese) { Dough = dough; Sauce = sauce; Clams = clams; Cheese = cheese; }
public void CopyTo(ICheese cheese) { cheese.BestBeforeDate = BestBeforeDate; cheese.DaysToSell = DaysToSell; cheese.Name = Name; cheese.Price = Price; cheese.Type = Type; }
public ICheese[] CreateCheese() { ICheese[] cheeses = new ICheese[] { new Mozzarella(), new Parmesan() }; return(cheeses); }
public Tuple <bool, ValidationErrorType> Validate(ICheese cheese) { return(cheese.DaysToSell == 0 ? Tuple.Create <bool, ValidationErrorType>(false, ValidationErrorType.DaysToSellPassed) : (cheese.Price < 0 ? Tuple.Create <bool, ValidationErrorType>(false, ValidationErrorType.ExceededMinimumPrice) : (cheese.Price > 20 ? Tuple.Create <bool, ValidationErrorType>(false, ValidationErrorType.ExceededMaximumPrice) : Tuple.Create <bool, ValidationErrorType>(true, ValidationErrorType.None)))); }
public virtual void Prepare() { Console.WriteLine("Preparing: " + _name); _dough = _ingredientFactory.CreateDough(); _sauce = _ingredientFactory.CreateSauce(); _cheese = _ingredientFactory.CreateCheese(); _clams = _ingredientFactory.CreateClam(); _pepperoni = _ingredientFactory.CreatePepperoni(); _veggies = _ingredientFactory.CreateVeggies(); }
public Burrito(IngredientFactory ingredientFactory) { _poultry = ingredientFactory.GetPoultry(); _meat = ingredientFactory.GetMeat(); _vegetation = ingredientFactory.GetVegetation(); _cheese = ingredientFactory.GetCheese(); _guacomole = ingredientFactory.GetGuacomole(); _rice = ingredientFactory.GetRice(); _beans = ingredientFactory.GetBeans(); _creamCheese = ingredientFactory.GetCreamCheese(); _tomato = ingredientFactory.GetTomato(); _chili = ingredientFactory.GetChili(); }
public void CalculatePrice(ICheese cheese, DateTime now) { var clonedCheese = (ICheese)cheese.Clone(); var priceRule = _priceRuleContainer.GetRule(clonedCheese.Type); priceRule.Invoke(clonedCheese, now); var validationResult = clonedCheese.Validate(_cheeseValidator); var isValid = validationResult.Item1; var errorType = validationResult.Item2; if (!isValid) { var resolverRule = _priceResolversContainer.GetRule(errorType); resolverRule.Invoke(clonedCheese); } clonedCheese.CopyTo(cheese); }
static void Main(string[] args) { IPizzaIngredientFactory ingredientFactory = FactoryProvider.GetPizzaIngredientFactory("NY"); IDough dough = ingredientFactory.GetConcreteProduct <IDough>(); ISauce sauce = ingredientFactory.GetConcreteProduct <ISauce>(); ICheese cheese = ingredientFactory.GetConcreteProduct <ICheese>(); IVeggies veggies = ingredientFactory.GetConcreteProduct <IVeggies>(); IPepperoni pepperoni = ingredientFactory.GetConcreteProduct <IPepperoni>(); IClam clam = ingredientFactory.GetConcreteProduct <IClam>(); ingredientFactory.getStyle(); Console.WriteLine("Состав:"); dough.AboutMe(); sauce.AboutMe(); cheese.AboutMe(); veggies.AboutMe(); clam.AboutMe(); Console.WriteLine("\nЗаменим стиль\n"); ingredientFactory = FactoryProvider.GetPizzaIngredientFactory("Chicago"); dough = ingredientFactory.GetConcreteProduct <IDough>(); sauce = ingredientFactory.GetConcreteProduct <ISauce>(); cheese = ingredientFactory.GetConcreteProduct <ICheese>(); veggies = ingredientFactory.GetConcreteProduct <IVeggies>(); pepperoni = ingredientFactory.GetConcreteProduct <IPepperoni>(); clam = ingredientFactory.GetConcreteProduct <IClam>(); ingredientFactory.getStyle(); Console.WriteLine("Состав:"); dough.AboutMe(); sauce.AboutMe(); cheese.AboutMe(); veggies.AboutMe(); clam.AboutMe(); Console.ReadKey(); }
public static Burger Create(string name, ICheese cheese) { return(new Burger(name, cheese)); }
public Burger(string name, ICheese cheese) { Name = name; Cheese = cheese; }
public Burger(ICheese cheese) { Cheese = cheese; }