Advertisement
LEANDRONIEVA

PC-maintp1

Aug 27th, 2023
1,210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.32 KB | None | 0 0
  1. public class Maintp1 {
  2.  
  3.     public static void main(String[] args) {
  4.         // TODO Auto-generated method stub
  5.         Cuenta cuenta1 = crearCuentaAle();
  6.         System.out.println(cuenta1.toString());
  7.         CuentaSueldo cuenta2 = crearCuentaSueldoAle();
  8.         System.out.println(cuenta2.toString());
  9.         CuentaSueldo cuenta3 = crearCuentaSueldoAle();
  10.         System.out.println(cuenta3.toString());
  11.        
  12.         cuenta1.ingresar(10000);
  13.         cuenta1.ingresar(30000);
  14.         cuenta1.retirar(15000);
  15.        
  16.         System.out.println(cuenta1.toString());
  17.        
  18.         cuenta1.actualizarSaldo();
  19.         System.out.println(cuenta1.toString());
  20.        
  21.         cuenta2.retirar(18000);
  22.        
  23.         System.out.println(cuenta2.toString());
  24.     }
  25.  
  26.     public static Cuenta crearCuentaAle() {
  27.         Random ale = new Random();
  28.         long dni = ale.nextLong(5000000,50000000);
  29.         double saldo = ale.nextDouble(10000,50000);
  30.         double interes = 0.2;
  31.        
  32.         Cuenta aux = new Cuenta(dni,saldo,interes);
  33.  
  34.         return aux;
  35.     }
  36.    
  37.     public static CuentaSueldo crearCuentaSueldoAle() {
  38.         Random ale = new Random();
  39.         long dni = ale.nextLong(5000000,50000000);
  40.         double saldo = ale.nextDouble(10000,50000);
  41.         double interes = 0.2;  
  42.         long cbu = ale.nextLong(1000000000000000000L,1999999999999999999L);
  43.        
  44.         CuentaSueldo aux = new CuentaSueldo(cbu);
  45.  
  46.         aux.setDni(dni);
  47.         aux.setSaldo(saldo);
  48.         aux.setInteres(interes);
  49.        
  50.         return aux;
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement