Advertisement
LEANDRONIEVA

PC-clasecuentatp1

Aug 27th, 2023 (edited)
1,285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.26 KB | None | 0 0
  1. public class Cuenta {
  2.     private static long aux = 100001;
  3.     protected long Nro = aux;
  4.     protected long Dni;
  5.     protected double saldo;
  6.     protected double interes;
  7.  
  8.     public Cuenta() {
  9.         super();
  10.         aux++;
  11.     }
  12.  
  13.     public Cuenta(long dni, double saldo, double interes) {
  14.         super();
  15.         Dni = dni;
  16.         this.saldo = saldo;
  17.         this.interes = interes;
  18.         aux++;
  19.     }
  20.    
  21.     public long getDni() {
  22.         return Dni;
  23.     }
  24.  
  25.     public void setDni(long dni) {
  26.         Dni = dni;
  27.     }
  28.  
  29.     public double getSaldo() {
  30.         return saldo;
  31.     }
  32.  
  33.     public void setSaldo(double saldo) {
  34.         this.saldo = saldo;
  35.     }
  36.  
  37.     public double getInteres() {
  38.         return interes;
  39.     }
  40.  
  41.     public void setInteres(double interes) {
  42.         this.interes = interes;
  43.     }
  44.  
  45.     public void actualizarSaldo() {
  46.         this.saldo += (this.interes/365);
  47.     }
  48.    
  49.     public void ingresar(double cantidad) {
  50.         this.saldo+= cantidad;
  51.         System.out.println("Se ingresó $"+cantidad);
  52.     }
  53.    
  54.     public void retirar(double cantidad) {
  55.         if(cantidad>this.saldo) {
  56.             System.out.println("Su saldo es insuficiente");
  57.         }else {
  58.             this.saldo -= cantidad;
  59.             System.out.println("Se retiró $"+cantidad);
  60.         }
  61.     }
  62.  
  63.     @Override
  64.     public String toString() {
  65.         return "Cuenta [Nro=" + Nro + ", Dni=" + Dni + ", saldo=" + saldo + ", interes=" + interes + "]";
  66.     }  
  67. }
  68.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement