//function to add some items at start of program static void AddSomeItemsToMenu() { ChickenBurger a = new ChickenBurger(); a.Name = "American Burger"; a.Price = 25; a.HasPickle = true; a.Calories = 550; restaurant.AddItem(a); HotDrink d = new HotDrink(); d.Name = "Capuccino"; d.Price = 10; d.Volume = 250; d.HasCaffeine = true; restaurant.AddItem(d); ColdDrink e = new ColdDrink(); e.Name = "Beer"; e.Price = 10; e.Volume = 250; e.HasSugar = true; restaurant.AddItem(e); }
static void HaveADrink(HotDrink h) { h.AddMilk(); h.Drink(); if (h is ICup) { ICup cupOfDrink = h as ICup; //ICup cupOfDrink =(ICup)h; cupOfDrink.Wash(); } }
static void UseHotdrinks(HotDrink hotDrink) { hotDrink.AddMilk(); hotDrink.Drink(); // Book Solution // Because not all HotDrinks have to be ICups, check if (hotDrink is ICup) { ((ICup)hotDrink).Wash(); } }
//add new item //lazy implementation static void AddItem() { try { Console.WriteLine("Item Types: cburger | vburger | colddrink | hotdrink"); Console.Write("Item Type:"); String type = Console.ReadLine(); MenuItem item; switch (type) { case "cburger": item = new ChickenBurger(); break; case "vburger": item = new VegBurger(); break; case "colddrink": item = new ColdDrink(); break; case "hotdrink": item = new HotDrink(); break; default: Console.WriteLine("Wrong type of item!"); return; } foreach (var prop in item.GetType().GetProperties()) { if (prop.Name.Equals("Id")) { continue; } Console.Write("{0}=", prop.Name); prop.SetValue(item, ParseAnyObject(Console.ReadLine())); } restaurant.AddItem(item); } catch (Exception e) { Console.WriteLine("Wrong input!"); Console.WriteLine(e.ToString()); } }
public ActionResult Select(DrinkTypes type) { var drink = new DrinkMaker(); var messages = new List <string>(); messages.Add(drink.BoilWater()); messages.Add(drink.AddPowder(type)); messages.Add(drink.PourDrink(type)); messages.Add(drink.AddExtras(type)); var hotDrink = new HotDrink(); hotDrink.Label = type.ToString(); hotDrink.Messages = messages; return(View(hotDrink)); }
static void ManipulateDrink(HotDrink drink) { ICup cupInterface = drink as ICup; cupInterface.Wash(); }