Beispiel #1
0
        public Lata ExtraerLata(string texto, double importe)
        {
            Lata retorno = null;

            this._dinero += importe;
            retorno       = BuscarLata(texto);
            this._latas.Remove(retorno);
            return(retorno);
        }
Beispiel #2
0
 public void AgregarLata(Lata lata)
 {
     if (this._latas.Count >= this._capacidad)
     {
         throw new CapacidadInsuficienteException();
     }
     else
     {
         this._latas.Add(lata);
     }
 }
Beispiel #3
0
        public Lata BuscarLata(string cod)
        {
            Lata lata = null;

            foreach (Lata a in _latas)
            {
                if (a.Codigo == cod)
                {
                    lata = a;
                }
            }

            return(lata);
        }
Beispiel #4
0
        static void IngresarLata(Expendedora exp)
        {
            Lata lata;

            if (!exp.Encendida)
            {
                Console.WriteLine("Debe encender la maquina para hacer esta operacion.");
            }
            else
            {
                try
                {
                    Console.WriteLine(exp.Listado());
                    lata = exp.BuscarLata(Validaciones.Texto("codigo").ToUpper());
                    if (lata == null)
                    {
                        throw new CodigoInvalidoException();
                    }
                    else
                    {
                        double precio  = Validaciones.Importe("precio");
                        double volumen = Validaciones.Importe("volumen en cc");
                        Lata   auxLata = new Lata(lata.Codigo, lata.Nombre, lata.Sabor, precio, volumen);
                        exp.AgregarLata(auxLata);

                        Console.WriteLine("Lata agregada ok.");
                    }
                }
                catch (CodigoInvalidoException ex)
                {
                    Console.WriteLine(ex.Message);
                }
                catch (CapacidadInsuficienteException)
                {
                    Console.WriteLine("La capacidad esta llena. No se agrega producto.");
                }
            }
        }