static void Main(string[] args) { Estanteria <Alimenticio> est1 = new Estanteria <Alimenticio>(5); Estanteria <Ferreteria> est2 = new Estanteria <Ferreteria>(5); Estanteria <Alimenticio> est3 = new Estanteria <Alimenticio>(5); DateTime d1 = new DateTime(1); DateTime d2 = new DateTime(2); Alimenticio alimento1 = new Alimenticio(5, "Verdura", d1); Alimenticio alimento2 = new Alimenticio(6, "Bebida", d2); Alimenticio alimento3 = new Alimenticio(7, "Snack", d1); Alimenticio alimento4 = new Alimenticio(8, "Carne", d1); Alimenticio alimento5 = new Alimenticio(9, "Pollo", d2); Alimenticio alimento6 = new Alimenticio(8, "AlimentoRepetido", d1); Ferreteria ferre1 = new Ferreteria(23, "Martillo", 20); Ferreteria ferre2 = new Ferreteria(24, "Destornillador", 25); Ferreteria ferre3 = new Ferreteria(25, "Lija", 30); Ferreteria ferre4 = new Ferreteria(26, "Tornillo", 5); Ferreteria ferre5 = new Ferreteria(27, "Regla", 10); Ferreteria ferre6 = new Ferreteria(26, "FerreRepetida", 30); Console.WriteLine("ESTANTE 1: "); if (est1 + alimento1) { Console.WriteLine("Alimento 1 ha sido agregado (Verdura)"); } else { Console.WriteLine("No pudo agregarse"); } if (est1 + alimento1) { Console.WriteLine("Alimento 1 ha sido agregado (Verdura)"); } else { Console.WriteLine("No pudo agregarse"); } if (est1 + ferre2) { Console.WriteLine("Pudo agregarse"); } else { Console.WriteLine("No pudo agregarse"); } Console.ReadKey(); }
static void Main(string[] args) { Estanteria <Ferreteria> e1 = new Estanteria <Ferreteria>(3); Estanteria <Producto> e2 = new Estanteria <Producto>(3); Estanteria <Alimenticio> e3 = new Estanteria <Alimenticio>(3); Alimenticio alimento1 = new Alimenticio(1, "arroz", new DateTime(2020, 05, 07)); Alimenticio alimento2 = new Alimenticio(2, "fideos", new DateTime(2022, 10, 23)); Ferreteria ferrete1 = new Ferreteria(3, "pinza", 35.6f); Ferreteria ferrete2 = new Ferreteria(4, "clavos", 1.5f); bool b1 = e3 + alimento1; bool b2 = e3 + alimento2; bool b3 = e1 + ferrete1; bool b4 = e1 + ferrete2; }
static void Main(string[] args) { bool flag; Estanteria <Producto> estanteria1 = new Estanteria <Producto>(5); Estanteria <Alimenticio> estanteria2 = new Estanteria <Alimenticio>(5); Estanteria <Ferreteria> estanteria3 = new Estanteria <Ferreteria>(5); Alimenticio alimenticioGenerico = new Alimenticio(1, "Alimento Generico", new DateTime(2019, 10, 21)); Ferreteria ferreteriaGenerico = new Ferreteria(2, "Herramienta Generica", 25.5f); flag = estanteria2 + alimenticioGenerico; flag = estanteria3 + ferreteriaGenerico; Console.WriteLine(estanteria2.Productos[0].Descripcion); Console.WriteLine(estanteria3.Productos[0].Descripcion); Console.ReadKey(); }
static void Main(string[] args) { //Fecha de hoy DateTime fecha = DateTime.Today; // Instancio Estanterias. Estanteria <Producto> estProductos = new Estanteria <Producto>(50); Estanteria <Alimenticio> estAlimenticio = new Estanteria <Alimenticio>(50); Estanteria <Ferreteria> estFerreteria = new Estanteria <Ferreteria>(50); //Creo Productos. Alimenticio arroz = new Alimenticio(1, "Arroz", new DateTime()); Alimenticio leche = new Alimenticio(2, "Leche", fecha); Alimenticio aceite = new Alimenticio(3, "Aceite", fecha); Ferreteria tornillo = new Ferreteria(4, "Tornillo", (float)30.5); Ferreteria bulon = new Ferreteria(5, "Bulon", (float)4.5); Ferreteria tuerca = new Ferreteria(6, "Tuerca", (float)2.5); // Agrego al estante (Ferreteria) Console.WriteLine("**Si esta bien, agrega 3 prod. Ferreteria."); Console.WriteLine(""); if (estFerreteria + tornillo) { Console.WriteLine("Agrege Tornillo a Estante de Ferreteria"); } if (estFerreteria + bulon) { Console.WriteLine("Agrege bulon a Estante de Ferreteria"); } if (estFerreteria + tuerca) { Console.WriteLine("Agrege tuerca a Estante de Ferreteria"); } Console.WriteLine(""); // Agrego al estante (Alimenticio) Console.WriteLine("**Si esta bien, agrega 3 prod. Alimenticio."); Console.WriteLine(""); if (estAlimenticio + arroz) { Console.WriteLine("Agrege arroz a Estante de Alimenticio"); } if (estAlimenticio + aceite) { Console.WriteLine("Agrege aceite a Estante de Alimenticio"); } if (estAlimenticio + leche) { Console.WriteLine("Agrege leche a Estante de Alimenticio"); } Console.WriteLine(""); // Agrego al estante (General) Console.WriteLine("**Si esta bien, agrega 4 prod. Generales."); Console.WriteLine(""); if (estProductos + arroz) { Console.WriteLine("Agrege arroz a Estante de Productos Generales"); } if (estProductos + bulon) { Console.WriteLine("Agrege bulon a Estante de Productos Generales"); } if (estProductos + leche) { Console.WriteLine("Agrege leche a Estante de Productos Generales"); } if (estProductos + tornillo) { Console.WriteLine("Agrege leche a Estante de Productos Generales"); } Console.WriteLine(""); //Quito elementos. Console.WriteLine("**Si esta bien, QUITO 4 prod. Generales."); Console.WriteLine(""); if (estProductos - arroz) { Console.WriteLine("Quite arroz a Estante de Productos Generales"); } if (estProductos - bulon) { Console.WriteLine("Quite bulon a Estante de Productos Generales"); } if (estProductos - leche) { Console.WriteLine("Quite leche a Estante de Productos Generales"); } if (estProductos - tornillo) { Console.WriteLine("Quite tornillo a Estante de Productos Generales"); } Console.ReadKey(); }