Пример #1
0
 private static void GuardarEstante(string filename, Estante e)
 {
     using (TextWriter writer = new StreamWriter(filename, true))
     {
         foreach (Producto p in e.GetProductos())
         {
             string line = p.ToString();
             writer.WriteLine(line);
         }
     }
 }
Пример #2
0
        private static void SerializarEstante(string filexmlName, Estante e)
        {
            XmlDocument doc  = new XmlDocument();
            XmlElement  raiz = doc.CreateElement("estante");

            doc.AppendChild(raiz);


            foreach (Producto p in e.GetProductos())
            {
                XmlElement producto = doc.CreateElement("producto");
                raiz.AppendChild(producto);
                XmlElement marca = doc.CreateElement("marca");
                marca.AppendChild(doc.CreateTextNode(p.Marca.ToString()));
                producto.AppendChild(marca);
                XmlElement precio = doc.CreateElement("precio");
                precio.AppendChild(doc.CreateTextNode(p.Precio.ToString()));
                producto.AppendChild(precio);
                XmlElement codigo = doc.CreateElement("codigo");
                codigo.AppendChild(doc.CreateTextNode(((int)p).ToString()));
                producto.AppendChild(codigo);
            }
            doc.Save(filexmlName);
        }
Пример #3
0
        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.Diversión, 500f);
            Jugo      j1 = new Jugo(112, 25f, Producto.EMarcaProducto.Naranjú, 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(Producto.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 - Producto.ETipoProducto.Galletita;
            Console.WriteLine("Estante1 sin Galletitas: {0}", Estante.MostrarEstante(est1));
            Console.WriteLine("Contenido Estante2:\n{0}", Estante.MostrarEstante(est2));
            est2 -= Producto.ETipoProducto.Todos;
            Console.WriteLine("Contenido Estante2:\n{0}", Estante.MostrarEstante(est2));
            Console.ReadLine();
        }
Пример #4
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();
        }
Пример #5
0
        public void sort(Estante e)
        {
            List <Producto> productos = e.GetProductos();

            productos.Sort()
        }