Advertisement
iNoobAvicena

Bunga Rekening Class

Mar 26th, 2022
867
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package buatbunga;
  2.  
  3. class Rekening {
  4.    
  5.     private String nama;
  6.     int id;
  7.     private Transaksi[] transaksi;
  8.     private int saldo;
  9.    
  10.     public Rekening(final String nama) {
  11.         this.id = 0;
  12.         this.transaksi = new Transaksi[3];
  13.         this.saldo = 0;
  14.         this.nama = nama;
  15.     }
  16.  
  17.     public Integer getSaldo() {
  18.         return saldo;
  19.     }
  20.  
  21.     public int simpanSaldo(int jumlah) {
  22.         return saldo += jumlah;
  23.     }
  24.    
  25.     public void addTransaksi(final Transaksi x) {
  26.         this.transaksi[this.id] = x;
  27.         ++this.id;
  28.     }
  29.    
  30.     public void printTransaksi() {
  31.         System.out.println("");
  32.         for (int i = 0; i < this.id; ++i) {
  33.             System.out.println("=============== Transaksi ==============");
  34.             this.transaksi[i].detailTransaksi();
  35.             System.out.println("========================================");
  36.             System.out.println("");
  37.         }
  38.     }
  39. }
Advertisement
RAW Paste Data Copied
Advertisement