Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- /**
- * class ini digunakan untuk memproses transaksi yang dilakukan oleh user
- * dan menampilkannya dalam bentuk kalimat
- *
- * @author Dwinanda Bagoes Ansori
- * @version 24 November 2020
- */
- public class Transaction
- {
- int value = -1;
- int query = 0;
- int pecahan = 0;
- int lembar;
- int total;
- Account acc;
- Scanner SC = new Scanner(System.in);
- public Transaction(int trans, Account acc)
- {
- System.out.println();
- this.acc = acc;
- switch (trans)
- {
- case 1 :
- System.out.println("1. Rp 50.000");
- System.out.println("2. Rp 100.000");
- System.out.print("Pilih Pecahan : ");
- query = SC.nextInt();
- if(query == 1)
- {
- this.pecahan = 50000;
- }
- else if(query == 2)
- {
- this.pecahan = 100000;
- }
- else
- {
- break;
- }
- System.out.print("Jumlah lembar : ");
- lembar = SC.nextInt();
- toStringSetor();
- break;
- case 3 :
- System.out.println("Saldo Anda : Rp " + acc.getSaldo());
- break;
- }
- }
- // method untuk mengubah transaksi setor dalam bentuk string
- private void toStringSetor()
- {
- total = pecahan*lembar;
- System.out.println("Data Setoran : ");
- System.out.println("Rp " + pecahan + " x " + lembar + " = " + (total));
- System.out.println("TOTAL = " + (total));
- System.out.println("1. Setor");
- System.out.println("2. Batal");
- query = SC.nextInt();
- if(query == 1)
- {
- System.out.println("Uang Berhasil Disetor");
- acc.updateSetor(total); // update saldo user
- }
- else
- {
- System.out.println("Uang Gagal Disetor");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment