Beispiel #1
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)10.5);
            Producto p2 = new Producto("Coca-Cola", "COSDS55752", (float)10.5);
            Producto p3 = new Producto("Manaos", "MASDS51292", (float)10.5);
            Producto p4 = new Producto("Crush", "CRSDS54861", (float)10.5);

            // Agrego los productos al estante
            if (estante + p1)
            {
                Console.WriteLine((string)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());
            Console.ReadKey();
        }
Beispiel #2
0
        public static string MostrarEstante(Estante e)
        {
            string aux = "";

            foreach (Producto p in e.productos)
            {
                aux = aux + Producto.MostrarProducto(p) + "\n";
            }
            return(aux);
        }
        static void Main(string[] args)
        {
            Estante estante = new Estante(3, 1);

            Producto p1 = new Producto("Manzana", "P2P3P4P5", (float)20.30);
            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);

            if (estante + p1)
            {
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine("\nAgregó: Marca: {0} Codigo: {1} Precio: {2}", p1.GetMarca(), (string)p1, p1.GetPrecio());
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.DarkRed;
                Console.WriteLine("\nNo agregó: Marca: {0} Codigo: {1} Precio: {2}", p1.GetMarca(), (string)p1, p1.GetPrecio());
            }
            if (estante + p2)
            {
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine("\nAgregó: Marca: {0} Codigo: {1} Precio: {2}", p2.GetMarca(), (string)p2, p2.GetPrecio());
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.DarkRed;
                Console.WriteLine("\nNo agregó: Marca: {0} Codigo: {1} Precio: {2}", p2.GetMarca(), (string)p2, p2.GetPrecio());
            }
            if (estante + p3)
            {
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine("\nAgregó: Marca: {0} Codigo: {1} Precio: {2}", p3.GetMarca(), (string)p3, p3.GetPrecio());
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.DarkRed;
                Console.WriteLine("\nNo agregó: Marca: {0} Codigo: {1} Precio: {2}", p3.GetMarca(), (string)p3, p3.GetPrecio());
            }
            if (estante + p4)
            {
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine("\nAgregó: Marca: {0} Codigo: {1} Precio: {2}", p4.GetMarca(), (string)p4, p4.GetPrecio());
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.DarkRed;
                Console.WriteLine("\nNo agregó: Marca: {0} Codigo: {1} Precio: {2}", p4.GetMarca(), (string)p4, p4.GetPrecio());
            }
            Console.WriteLine();
            Console.WriteLine("<------------------------------------------------->");
            Console.Write(Estante.MostrarEstante(estante));
            Console.ReadKey();
        }
Beispiel #4
0
        //6) El método público de clase MostrarEstante, retornará una cadena con toda la información del
        //estante, incluyendo el detalle de cada uno de sus productos.Reutilizar código.

        public static string MostrarEstante(Estante e)
        {
            string retorno;

            retorno = e.ubicacionEstante.ToString() + " ";

            foreach (Producto producto in e.productos)
            {
                if (!(e.productos is null)) //si es verdadero
                {
                    retorno += Producto.MostrarProducto(producto);
                }
            }
            return(retorno);
        }
        public static string MostrarEstante(Estante e)
        {
            StringBuilder retorno = new StringBuilder();
            string        retornoString;

            retorno.AppendLine("Ubicacion estante: " + e.ubicacionEstante);
            retorno.AppendLine("Capacidad: " + e.productos.Length);
            retorno.AppendLine("Productos: ");
            foreach (Producto p in e.productos)
            {
                retorno.Append(Producto.MostrarProducto(p));
            }

            retornoString = retorno.ToString();

            return(retornoString);
        }
 public static string MostrarEstante(Estante e)
 {
     Console.ForegroundColor = ConsoleColor.White;
     return("\nUbicacion del estante: " + e.ubicacionEstante + "\nProductos: " + e.GetProducto());
 }