Example #1
0
 private static void GuardarEstante(string filename, Estante e)
 {
     using (TextWriter writer = new StreamWriter(filename, true))
     {
         writer.Write(Estante.MostrarEstante(e));
     }
 }
Example #2
0
        static void Main(string[] args)
        {
            // Creo un estante
            Estante estante = new Estante(3, 1);
            // Creo 4 productos
            Producto p1 = new Producto("Pepsi", "PESDS97413", (float)18.5);
            Producto p2 = new Producto("Coca-Cola", "COSDS55752", (float)11.5);
            Producto p3 = new Producto("Manaos", "MASDS51292", (float)20.5);
            Producto p4 = new Producto("Crush", "CRSDS54861", (float)10.75);

            // Agrego los productos al estante
            if (estante + p1)
            {
                Console.WriteLine("Agregó {0} {1} {2}", p1.GetMarca(), (string)p1, p1.GetPrecio());
            }
            else
            {
                Console.WriteLine("¡NO agregó {0} {1} {2}!", p1.GetMarca(), (string)p1, p1.GetPrecio());
            }
            if (estante + p1)
            {
                Console.WriteLine("Agregó {0} {1} {2}", p1.GetMarca(), (string)p1, p1.GetPrecio());
            }
            else
            {
                Console.WriteLine("¡NO agregó {0} {1} {2}!", p1.GetMarca(), (string)p1, p1.GetPrecio());
            }
            if (estante + p2)
            {
                Console.WriteLine("Agregó {0} {1} {2}", p2.GetMarca(), (string)p2, p2.GetPrecio());
            }
            else
            {
                Console.WriteLine("¡NO agregó {0} {1} {2}!", p2.GetMarca(), (string)p2, p2.GetPrecio());
            }
            if (estante + p3)
            {
                Console.WriteLine("Agregó {0} {1} {2}", p3.GetMarca(), (string)p3, p3.GetPrecio());
            }
            else
            {
                Console.WriteLine("¡NO agregó {0} {1} {2}!", p3.GetMarca(), (string)p3, p3.GetPrecio());
            }
            if (estante + p4)
            {
                Console.WriteLine("Agregó {0} {1} {2}", p4.GetMarca(), (string)p4, p4.GetPrecio());
            }
            else
            {
                Console.WriteLine("¡NO agregó {0} {1} {2}!", p4.GetMarca(), (string)p4, p4.GetPrecio());
            }
            // Muestro todo el estante
            Console.WriteLine();
            Console.WriteLine("<------------------------------------------------->");
            Console.WriteLine(Estante.MostrarEstante(estante));

            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            Console.Title = "Primer Parcial Laboratorio II - 2016 -";

            Estante est1 = new Estante(4); Estante est2 = new Estante(3);

            Harina h1 = new Harina(102, 37.5f, Producto.EMarcaProducto.Favorita, Harina.ETipoHarina.CuatroCeros); Harina h2 = new Harina(103, 40.25f, Producto.EMarcaProducto.Favorita, Harina.ETipoHarina.Integral); Galletita g1 = new Galletita(113, 33.65f, Producto.EMarcaProducto.Pitusas, 250f); Galletita g2 = new Galletita(111, 56f, Producto.EMarcaProducto.Diversion, 500f); Jugo j1 = new Jugo(112, 25f, Producto.EMarcaProducto.Naranju, Jugo.ESaborJugo.Pasable); Jugo j2 = new Jugo(333, 33f, Producto.EMarcaProducto.Swift, Jugo.ESaborJugo.Asqueroso); //Gaseosa g = new Gaseosa(j2, 2250f);

            if (!(est1 + h1))
            {
                Console.WriteLine("No se pudo agregar el producto al estante!!!");
            }
            if (!(est1 + g1))
            {
                Console.WriteLine("No se pudo agregar el producto al estante!!!");
            }
            if (!(est1 + g2))
            {
                Console.WriteLine("No se pudo agregar el producto al estante!!!");
            }
            if (!(est1 + g1))
            {
                Console.WriteLine("No se pudo agregar el producto al estante!!!");
            }
            if (!(est1 + j1))
            {
                Console.WriteLine("No se pudo agregar el producto al estante!!!");
            }
            if (!(est2 + h2))
            {
                Console.WriteLine("No se pudo agregar el producto al estante!!!");
            }
            if (!(est2 + j2))
            {
                Console.WriteLine("No se pudo agregar el producto al estante!!!");
            }
            //if (!(est2 + g)) { Console.WriteLine("No se pudo agregar el producto al estante!!!"); }
            if (!(est2 + g1))
            {
                Console.WriteLine("No se pudo agregar el producto al estante!!!");
            }

            Console.WriteLine("Valor total Estante1: {0}", est1.ValorEstanteTotal);

            Console.WriteLine("Valor Estante1 sólo de Galletitas: {0}", est1.GetValorEstante(ETipoProducto.Galletita));

            Console.WriteLine("Contenido Estante1:\n{0}", Estante.MostrarEstante(est1));

            //Console.WriteLine("Estante ordenado por Código de Barra...."); est1.GetProductos().Sort(Program.OrdenarProductos); Console.WriteLine(Estante.MostrarEstante(est1));

            est1 = est1 - ETipoProducto.Galletita; Console.WriteLine("Estante1 sin Galletitas: {0}", Estante.MostrarEstante(est1));

            Console.WriteLine("Contenido Estante2:\n{0}", Estante.MostrarEstante(est2)); est2 -= ETipoProducto.Todos; Console.WriteLine("Contenido Estante2:\n{0}", Estante.MostrarEstante(est2));

            Console.ReadLine();
        }
        private void btnOrdenar_Click(object sender, EventArgs e)
        {
            rtxtSalida.Text = "";
            Estante est1;
            Estante est2;

            this.CargarEstante(out est1, out est2);
            rtxtSalida.Text += "Estante 1 ordenado por Marca....\n";
            est1.GetProductos().Sort(FormEstante.OrdenarProductos);
            rtxtSalida.Text += Estante.MostrarEstante(est1);
            rtxtSalida.Text += "Estante 2 ordenado por Marca....\n";
            est2.GetProductos().Sort(FormEstante.OrdenarProductos);
            rtxtSalida.Text += Estante.MostrarEstante(est2);
        }
Example #5
0
        private void btnEjecutar_Click(object sender, EventArgs e)
        {
            rtxtSalida.Text = "";
            Estante est1;
            Estante est2;

            this.CargarEstante(out est1, out est2);
            rtxtSalida.Text += String.Format("Valor total Estante1: {0}", est1.ValorEstanteTotal);
            rtxtSalida.Text += String.Format("Valor Estante1 sólo de Galletitas: {0}", est1.GetValorEstante(Producto.ETipoProducto.Galletita));
            rtxtSalida.Text += String.Format("Contenido Estante1:\n{0}", Estante.MostrarEstante(est1));
            rtxtSalida.Text += "Estante ordenado por Marca....\n";
            est1.GetProductos().Sort(FormEstante.Form1.OrdenarProductos);
            rtxtSalida.Text += Estante.MostrarEstante(est1);
            est1             = est1 - Producto.ETipoProducto.Galletita;
            rtxtSalida.Text += String.Format("Estante1 sin Galletitas: {0}", Estante.MostrarEstante(est1));
            rtxtSalida.Text += String.Format("Contenido Estante2:\n{0}", Estante.MostrarEstante(est2));
            est2            -= Producto.ETipoProducto.Todos;
            rtxtSalida.Text += String.Format("Contenido Estante2:\n{0}", Estante.MostrarEstante(est2));
        }
Example #6
0
        static void Main(string[] args)
        {
            Estante est1 = new Estante(3);
            Estante est2 = new Estante(2);

            Producto  p  = new Producto(222, EMarcaProducto.Manaos, 50.25f);
            Galletita g1 = new Galletita(113, 33.65f, EMarcaProducto.Pitusas, 250f);
            Galletita g2 = new Galletita(111, 56f, EMarcaProducto.Diversión, 500f);
            Jugo      j1 = new Jugo(112, 25f, EMarcaProducto.Naranjú, ESaborJugo.Pasable);
            Jugo      j2 = new Jugo(333, 33f, EMarcaProducto.Swift, ESaborJugo.Asqueroso);
            Gaseosa   g  = new Gaseosa(p, 2250f);

            if (!(est1 + g1))
            {
                Console.WriteLine("No se pudo agregar el producto al estante!!!");
            }
            if (!(est1 + g2))
            {
                Console.WriteLine("No se pudo agregar el producto al estante!!!");
            }
            if (!(est1 + g1))
            {
                Console.WriteLine("No se pudo agregar el producto al estante!!!");
            }
            if (!(est1 + j1))
            {
                Console.WriteLine("No se pudo agregar el producto al estante!!!");
            }

            if (!(est2 + g))
            {
                Console.WriteLine("No se pudo agregar el producto al estante!!!");
            }
            if (!(est2 + p))
            {
                Console.WriteLine("No se pudo agregar el producto al estante!!!");
            }
            if (!(est2 + j2))
            {
                Console.WriteLine("No se pudo agregar el producto al estante!!!");
            }

            Console.WriteLine(est1.ValorEstanteTotal);
            Console.WriteLine(est1.GetValorEstante(ETipoProducto.Galletita));
            Console.WriteLine(Estante.MostrarEstante(est1));

            Console.WriteLine("Estante ordenado....");
            est1.GetProductos().Sort(Program.OrdenarProductos);
            Console.WriteLine(Estante.MostrarEstante(est1));


            est1 = est1 - ETipoProducto.Galletita;
            Console.WriteLine(Estante.MostrarEstante(est1));

            Console.ReadLine();

            Console.WriteLine(Estante.MostrarEstante(est2));
            est2 -= ETipoProducto.Todos;
            Console.WriteLine(Estante.MostrarEstante(est2));

            Console.ReadLine();
        }
Example #7
0
        static void Main(string[] args)
        {
            Console.Title           = "Practica integrador 01";
            Console.ForegroundColor = ConsoleColor.Green;

            #region Creates Products
            // Creo un estante
            Estante estante = new Estante(3, 1);
            // Creo 4 productos
            Producto p1 = new Producto("Pepsi", "PESDS97413", (float)18.5);
            Producto p2 = new Producto("Coca-Cola", "COSDS55752", (float)11.5);
            Producto p3 = new Producto("Manaos", "MASDS51292", (float)20.5);
            Producto p4 = new Producto("Crush", "CRSDS54861", (float)10.75);
            #endregion

            // Agrego los productos al estante
            #region Add the product to the shelf
            if (estante + p1)
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Agregó {0} {1} {2}", p1.GetMarca(), (string)p1, p1.GetPrecio());
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("¡NO agregó {0} {1} {2}!", p1.GetMarca(), (string)p1, p1.GetPrecio());
            }
            if (estante + p1)
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Agregó {0} {1} {2}", p1.GetMarca(), (string)p1, p1.GetPrecio());
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("¡NO agregó {0} {1} {2}!", p1.GetMarca(), (string)p1, p1.GetPrecio());
            }
            if (estante + p2)
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Agregó {0} {1} {2}", p2.GetMarca(), (string)p2, p2.GetPrecio());
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("¡NO agregó {0} {1} {2}!", p2.GetMarca(), (string)p2, p2.GetPrecio());
            }
            if (estante + p3)
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Agregó {0} {1} {2}", p3.GetMarca(), (string)p3, p3.GetPrecio());
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("¡NO agregó {0} {1} {2}!", p3.GetMarca(), (string)p3, p3.GetPrecio());
            }
            if (estante + p4)
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Agregó {0} {1} {2}", p4.GetMarca(), (string)p4, p4.GetPrecio());
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("¡NO agregó {0} {1} {2}!", p4.GetMarca(), (string)p4, p4.GetPrecio());
            }
            #endregion

            // Muestro todo el estante
            #region Shows The Shelf

            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine();
            Console.WriteLine("<------------------------------------------------->");
            Console.WriteLine(Estante.MostrarEstante(estante));
            Console.ReadKey();
            #endregion
        }
Example #8
0
        static void Main(string[] args)
        {
            // Creo un estante
            Estante estante = new Estante(3, 1);
            // Creo 4 productos
            Producto p1 = new Producto("Pepsi", "PESDS97413", (float)18.5);
            Producto p2 = new Producto("Coca-Cola", "COSDS55752", (float)11.5);
            Producto p3 = new Producto("Manaos", "MASDS51292", (float)20.5);
            Producto p4 = new Producto("Crush", "CRSDS54861", (float)10.75);

            Producto p5 = new Producto("Pepsi", "PESDS97413", (float)18.5);
            Producto p6;

            Console.WriteLine("{0}", (p1 == p2));
            Console.WriteLine("{0}", (p1.GetMarca() == p2.GetMarca()));
            Console.WriteLine("{0}", (p1 == p5));
            Console.WriteLine("{0}", (p1.GetMarca() == p5.GetMarca()));

            Console.WriteLine("{0}", (p1 != p2));
            Console.WriteLine("{0}", (p1.GetMarca() != p2.GetMarca()));
            Console.WriteLine("{0}", (p1 != p5));
            Console.WriteLine("{0}", (p1.GetMarca() != p5.GetMarca()));

            Estante estantePrueba = new Estante(5, 2);

            Producto [] produtoPrueba;
            produtoPrueba = new Producto[5];

            produtoPrueba[0] = p2;

            if (produtoPrueba is null)
            {
                Console.WriteLine("Esta vacio");
            }
            else
            {
                Console.WriteLine(produtoPrueba.Length);
                p6 = produtoPrueba[0];
                Console.WriteLine("Esto es producto 6: {0} {1} {2}", p6.GetMarca(), (string)p6, p6.GetPrecio());
                Console.WriteLine("No esta vacio");
            }

            if (estantePrueba + p1)
            {
                Console.WriteLine("Articulo agragado");
            }
            if (estantePrueba + p2)
            {
                Console.WriteLine("Articulo agragado");
            }
            if (estantePrueba + p3)
            {
                Console.WriteLine("Articulo agragado");
            }

            Console.WriteLine(Estante.MostrarEstante(estantePrueba));

            estantePrueba = (estantePrueba - p2);
            //
            Console.WriteLine(Estante.MostrarEstante(estantePrueba));

            estantePrueba = (estantePrueba - p3);
            Console.WriteLine(Estante.MostrarEstante(estantePrueba));

            if (estantePrueba + p4)
            {
                Console.WriteLine("Articulo agragado");
            }
            if (estantePrueba + p2)
            {
                Console.WriteLine("Articulo agragado");
            }
            if (estantePrueba + p3)
            {
                Console.WriteLine("Articulo agragado");
            }
            if (estantePrueba + p4)
            {
                Console.WriteLine("Articulo agragado");
            }

            Console.WriteLine(Estante.MostrarEstante(estantePrueba));
            Console.ReadKey();

            /*
             * // Agrego los productos al estante
             *
             * if (estante + p1)
             * {
             *      Console.WriteLine("Agregó {0} {1} {2}", p1.GetMarca(), (string)p1, p1.GetPrecio());
             * }
             * else
             * {
             *      Console.WriteLine("¡NO agregó {0} {1} {2}!", p1.GetMarca(), (string)p1, p1.GetPrecio());
             * }
             * if (estante + p1)
             * {
             *      Console.WriteLine("Agregó {0} {1} {2}", p1.GetMarca(), (string)p1, p1.GetPrecio());
             * }
             * else
             * {
             *      Console.WriteLine("¡NO agregó {0} {1} {2}!", p1.GetMarca(), (string)p1, p1.GetPrecio());
             * }
             * if (estante + p2)
             * {
             *      Console.WriteLine("Agregó {0} {1} {2}", p2.GetMarca(), (string)p2, p2.GetPrecio());
             * }
             * else
             * {
             *      Console.WriteLine("¡NO agregó {0} {1} {2}!", p2.GetMarca(), (string)p2, p2.GetPrecio());
             * }
             * if (estante + p3)
             * {
             *      Console.WriteLine("Agregó {0} {1} {2}", p3.GetMarca(), (string)p3, p3.GetPrecio());
             * }
             * else
             * {
             *      Console.WriteLine("¡NO agregó {0} {1} {2}!", p3.GetMarca(), (string)p3, p3.GetPrecio());
             * }
             * if (estante + p4)
             * {
             *      Console.WriteLine("Agregó {0} {1} {2}", p4.GetMarca(), (string)p4, p4.GetPrecio());
             * }
             * else
             * {
             *      Console.WriteLine("¡NO agregó {0} {1} {2}!", p4.GetMarca(), (string)p4, p4.GetPrecio());
             * }
             *
             * // Muestro todo el estante
             * Console.WriteLine();
             * Console.WriteLine("<------------------------------------------------->");
             *
             * Console.WriteLine(Estante.MostrarEstante(estante));
             */
            Console.ReadKey();
        }
Example #9
0
        static void Main(string[] args)
        {
            #region instancias
            Estante e1 = new Estante(4);
            Estante e2 = new Estante(6);


            Jugo j1 = new Jugo(1245, EMarcaProducto.Diversion, 2.50f, ESaborJugo.Asqueroso);
            Jugo j2 = new Jugo(4512, EMarcaProducto.Manaos, 2.50f, ESaborJugo.Pasable);
            Jugo j3 = new Jugo(5487, EMarcaProducto.Naranju, 2.50f, ESaborJugo.Rico);
            Jugo j4 = new Jugo(5487, EMarcaProducto.Pitusas, 2.50f, ESaborJugo.Asqueroso);

            Galletita g1 = new Galletita(4578, EMarcaProducto.Diversion, 10.00f, 500f);
            Galletita g2 = new Galletita(5469, EMarcaProducto.Manaos, 10.00f, 1000f);
            Galletita g3 = new Galletita(5214, EMarcaProducto.Naranju, 10.00f, 200f);
            Galletita g4 = new Galletita(5987, EMarcaProducto.Pitusas, 10.00f, 100f);

            Gaseosa gs1 = new Gaseosa(4515, EMarcaProducto.Diversion, 5.00f, 600f);
            Gaseosa gs2 = new Gaseosa(4578, EMarcaProducto.Manaos, 5.00f, 550f);
            Gaseosa gs3 = new Gaseosa(5548, EMarcaProducto.Swift, 5.00f, 550f);
            Gaseosa gs4 = new Gaseosa(3256, EMarcaProducto.Pitusas, 5.00f, 550f);
            #endregion

            if (e1 + j1)
            {
                e1.Productos.Add(j1);
            }
            if (e1 + j2)
            {
                e1.Productos.Add(j2);
            }
            if (e1 + g1)
            {
                e1.Productos.Add(g1);
            }
            if (e1 + gs1)
            {
                e1.Productos.Add(gs1);
            }
            if (e1 + gs2)
            {
                e1.Productos.Add(gs2);
            }

            Console.Write("Valor total del estante: ");
            Console.WriteLine(e1.ValorEstanteTotal.ToString());

            Console.ReadKey();
            Console.Clear();

            Console.Write("Valor solo de gaseosas: ");
            Console.WriteLine(e1.GetValorEstante(ETipoProducto.Gaseosa));

            Console.Write("Valor solo de Jugos: ");
            Console.WriteLine(e1.GetValorEstante(ETipoProducto.Jugo));

            Console.Write("Valor solo de galletitas: ");
            Console.WriteLine(e1.GetValorEstante(ETipoProducto.Galletita));

            Console.ReadKey();
            Console.Clear();

            Console.WriteLine(e1.MostrarEstante(e1));

            Console.ReadKey();
            Console.Clear();

            Console.WriteLine("Ordeno por codigo");
            e1.Productos.Sort(e1.OrdenarPorCodigo);
            Console.WriteLine(e1.MostrarEstante(e1));

            Console.ReadKey();
            Console.Clear();

            Console.WriteLine("Quito un jugo y muestro de nuevo el estante");
            e1 -= j2;
            Console.WriteLine(e1.MostrarEstante(e1));

            Console.ReadKey();
            Console.Clear();

            Console.WriteLine("Quito todos los jugos");
            e1 -= ETipoProducto.Jugo;
            Console.WriteLine(e1.MostrarEstante(e1));

            Console.ReadKey();
            Console.Clear();
        }