예제 #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("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();
        }
예제 #2
0
파일: Estante.cs 프로젝트: xTomluca/ProLab2
        public static string MostrarEstante(Estante e)
        {
            string        aux = "";
            StringBuilder str = new StringBuilder();

            for (int i = 0; i < e.capacidad; i++)
            {
                aux = e.productos[i].MostrarProducto(e.productos[i]);
                str.AppendFormat("{0} {1}", str, aux);
            }
            return(str.ToString());
        }
예제 #3
0
        public static string MostrarEstante(Estante e)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine(string.Format("Estante ubicacion: {0} productos: ", e.ubicacionEstante));
            foreach (Producto p in e.GetProductos())
            {
                sb.Append(Producto.MostrarProducto(p));
            }

            return(sb.ToString());
        }
        /// <summary>
        /// Elinina por Tipo de Producto del Estante si exite
        /// </summary>
        /// <param name="e"></param>
        /// <param name="tipo"></param>
        /// <returns>true o false</returns>
        public static Estante operator -(Estante e, ETipoProducto tipo)
        {
            Estante est = e;

            for (int i = 0; i < e._productos.Count; i++)
            {
                switch (tipo)
                {
                case ETipoProducto.Galletita:
                    if (est._productos[i] is Galletita)
                    {
                        est -= est._productos[i];
                        i--;
                    }
                    break;

                case ETipoProducto.Gaseosa:
                    if (est._productos[i] is Gaseosa)
                    {
                        est -= est._productos[i];
                        i--;
                    }
                    break;

                case ETipoProducto.Jugo:
                    if (est._productos[i] is Jugo)
                    {
                        est -= est._productos[i];
                        i--;
                    }
                    break;

                case ETipoProducto.Harina:
                    if (est._productos[i] is Jugo)
                    {
                        est -= est._productos[i];
                        i--;
                    }
                    break;

                case ETipoProducto.Todos:
                    if (e._productos.Count > 0)
                    {
                        est -= est._productos[i];
                        i--;
                    }
                    break;
                }
            }


            return(est);
        }
예제 #5
0
        public static string MostrarEstante(Estante e)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("Estante ubicacion: " + e.ubicacionEstante);
            foreach (Producto producto in e.GetProductos())
            {
                if (!(producto is null))
                {
                    sb.AppendLine(Producto.MostrarProducto(producto));
                }
            }
            return(sb.ToString());
        }
예제 #6
0
        public static string MostrarEstante(Estante e)
        {
            string ret;
            int    length;

            length = e.productos.Length;
            ret    = "Ubicacion del Estante = " + e.ubicacionEstante;
            for (int i = 0; i < length; i++)
            {
                if (e.productos[i] is null)
                {
                    return(ret);
                }
                ret = "\n" + ret + " " + Producto.MostrarProducto(e.productos[i]);
            }
            return(ret);
        }