Advertisement
Ramdan51-062

CashCheck

Oct 26th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.30 KB | None | 0 0
  1. public class CashCheck extends Transaction
  2. {
  3.     private int accountNumber;
  4.     private TollDatabase tollDatabase;
  5.     int tariff = 5000;  
  6.     private static Printer printer;
  7.     private static Gate gate;
  8.     public CashCheck(int userAccountNumber, TollDatabase gateTollDatabase)
  9.     {
  10.         super(userAccountNumber, gateTollDatabase);
  11.         gate = new Gate();
  12.         printer = new Printer();
  13.         tollDatabase = gateTollDatabase;
  14.     }
  15.    
  16.     @Override
  17.     public void execute()
  18.     {
  19.         boolean gateOpened = false;
  20.         int availableBalance, totalBalance;
  21.        
  22.         TollDatabase tollDatabase = new TollDatabase();
  23.        
  24.         availableBalance = tollDatabase.getAvailableBalance(getAccountNumber());
  25.        
  26.         if(availableBalance >= tariff)
  27.         {
  28.             System.out.println("\nSaldo anda sekarang: " + availableBalance);
  29.             gate.OpenGate();
  30.             System.out.print("\n");
  31.             tollDatabase.UseBalance(getAccountNumber(), tariff);
  32.             printer.PrintCheck(getAccountNumber(), tariff, tollDatabase.getAvailableBalance(getAccountNumber()));
  33.         }
  34.         else
  35.         System.out.println("Uang tidak mencukupi. Silahkan isi ulang");
  36.        
  37.        
  38.         if(gate.IsGateOpen() == true) gate.CloseGate();
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement