Exemplo n.º 1
0
 public void AgregarLata(Lata lata)
 {
     if (GetCapacidadRestante() > 0)
     {
         this._latas.Add(lata);
     }
     else
     {
         throw new CapacidadInsuficienteException();
     }
 }
Exemplo n.º 2
0
        public ResultadoExtraccion ExtraerLata(string codigo, double dinero)
        {
            Lata   lataAExtraer = null;
            double vueltoADar   = 0;

            foreach (Lata l in this._latas)
            {
                if (codigo == l.Codigo)
                {
                    if (dinero == l.Precio)
                    {
                        lataAExtraer = l;
                        vueltoADar   = 0;
                        this._latas.Remove(l);
                        this._dinero += dinero;
                        break;
                    }
                    else if (dinero > l.Precio)
                    {
                        lataAExtraer = l;
                        vueltoADar   = dinero - l.Precio;
                        this._latas.Remove(l);
                        this._dinero += l.Precio;
                        break;
                    }
                    else
                    {
                        throw new DineroInsuficienteException((l.Precio - dinero).ToString());
                    }
                }
            }
            if (lataAExtraer != null)
            {
                ResultadoExtraccion result = new ResultadoExtraccion(lataAExtraer, vueltoADar);
                return(result);
            }
            else
            {
                throw new SinStockException();
            }
        }
Exemplo n.º 3
0
 public ResultadoExtraccion(Lata lata, double vuelto)
 {
     this._lata   = lata;
     this._vuelto = vuelto;
 }