Advertisement
squidward98

Simulador Cajero Automático #1 Cuenta

Apr 6th, 2020
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.94 KB | None | 0 0
  1. package cajeroAutomatico;
  2.  
  3. public class Cuenta
  4. {
  5.     private int saldo;
  6.     private boolean estado = true;
  7.    
  8.     public Cuenta()
  9.     {
  10.         this.saldo = 0;
  11.     }
  12.    
  13.     public int getSaldo()
  14.     {
  15.         return this.saldo;
  16.     }
  17.    
  18.     public void setSaldo(int saldo)
  19.     {
  20.         this.saldo = saldo;
  21.     }
  22.    
  23.     public boolean isEstado()
  24.     {
  25.         return this.estado;
  26.     }
  27.    
  28.     public void setEstado(boolean estado)
  29.     {
  30.         this.estado = estado;
  31.     }
  32.    
  33.     public void ingresarDinero(int dinero)
  34.     {
  35.         this.saldo = this.getSaldo()    + dinero;
  36.     }
  37.    
  38.     public String sacarDinero(int dinero)
  39.     {
  40.         if(dinero > this.saldo || dinero < 0) return "Monto de dinero a extraer no permitido.";
  41.         else
  42.         {
  43.             this.saldo -= dinero;
  44.             return "Dinero extraido de la cuenta con éxito.";
  45.         }
  46.     }
  47.    
  48.     public boolean haySaldo()
  49.     {
  50.         if(this.saldo > 0) return true;
  51.         else return false;
  52.     }
  53.    
  54.     public int vaciarCuenta()
  55.     {
  56.         int vuelto = this.saldo;
  57.         this.setSaldo(0);
  58.         return vuelto;
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement