static void Main(string[] args) { Hamburguesa normal = new Hamburguesa(); Lechuga hamburguesaConLechuga = new Lechuga(normal); Lechuga hamburguesaConDobleLechuga = new Lechuga(hamburguesaConLechuga); Tomate hamburguesaConTomate = new Tomate(hamburguesaConDobleLechuga); //Mostramos los Ingrediente de la Hamburguesa Console.WriteLine(hamburguesaConTomate.getDescripcion()); Console.ReadKey(); }
static void Main(string[] args) { Pizza atum = new Atum(); Ingrediente tomate = new Tomate(atum); Ingrediente aliche = new Aliche(tomate); Ingrediente molhoextra = new MolhoExtra(aliche); Ingrediente queijo = new QueijoExtra(molhoextra); Console.WriteLine(String.Format("Valor Total da Pizza: {0}", queijo.RetornarPreco())); Console.ReadKey(); }
static void Main(string[] args) { Pizza atum = new Atum(); //princípio da inversão de dependencia Ingrediente tomate = new Tomate(atum); Ingrediente aliche = new Aliche(tomate); Console.WriteLine(String.Format("Valor Total da Pizza: {0}", aliche.RetornarPreco())); Console.ReadKey(); }