예제 #1
0
        public static Estante operator -(Estante est, Producto prod)
        {
            Estante estAux = est;

            if (estAux == prod)
            {
                estAux._productos.Remove(prod);
            }

            return(estAux);
        }
예제 #2
0
        public static Estante operator -(Estante est, ETipoProducto tipo)
        {
            Estante estAux = est;

            foreach (Producto item in estAux._productos)
            {
                if (item.GetType().ToString() == tipo.ToString())
                {
                    estAux._productos.Remove(item);
                }
            }

            return(estAux);
        }
예제 #3
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.Naranju, 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();
        }