Advertisement
squidward98

Simulador Cajero Automático #2 Cuenta

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