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();
        }
Exemple #2
0
        public static string MostrarEstante(Estante e)
        {
            if (e != null)
            {
                foreach (Producto row in e.productos)
                {
                    return("Estante:" + e.ubicacionEstante + row.MostrarProducto(row));
                }
            }

            return("ERROR");
        }
Exemple #3
0
        public static string MostrarEstante(Estante e)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine($"La ubicacion es :{e.ubicacionEstante}");
            foreach (Producto aux in e.productos)
            {
                sb.AppendLine($"Productos: {Producto.MostrarProducto(aux)}");
            }

            return(sb.ToString());
        }
Exemple #4
0
        public static string MostrarEstante(Estante x)
        {
            StringBuilder Str = new StringBuilder();

            //Str.AppendFormat($"En ubicacion {x.ubicacionEstante}\n");
            Str.AppendFormat("En ubicacion: {0}\n", x.ubicacionEstante);

            Str.AppendFormat("En ubicacion: \n " + x.ubicacionEstante + " asdads" + "dsdadsa");
            foreach (Producto producto in x.productos)
            {
                //Console.WriteLine($"{producto}");
                Str.AppendFormat("{0}\n", Producto.MostrarProducto(producto));
            }

            return(Str.ToString());
        }
Exemple #5
0
        public static string MostrarEstante(Estante e)
        {
            string salida = e.estanteriaUbicacion.ToString();

            foreach (Producto producto in e.productos)
            {
                if (!(producto is null))
                {
                    salida += Producto.MostrarProducto(producto);
                }
            }

            /*
             * for (int i = 0; i < e.productos.Length; i++)
             * {
             * Producto producto = e.productos[i];
             * }*/
            return(salida);
        }
Exemple #6
0
        public static Estante operator -(Estante z, Producto x)
        {
            Estante retorno = z;

            if (!(z is null) && !(x is null))
            {
                if (x == z)
                {
                    for (int i = 0; i < z.productos.Length; i++)
                    {
                        if (z.productos[i] == x)
                        {
                            z.productos[i] = null;
                            retorno        = z;
                        }
                    }
                }
            }
            return(retorno);
        }