taufiq123

Untitled

Oct 27th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.87 KB | None | 0 0
  1.  
  2. /**
  3.  * Write a description of class Transaction here.
  4.  *
  5.  * @author (your name)
  6.  * @version (a version number or a date)
  7.  */
  8. import java.util.Scanner;
  9. public class Transaction
  10. {  
  11.    int biayaTol;
  12.    int currentMoney;
  13.    String pengendara;
  14.    private boolean vechileAuthenticated;
  15.    private boolean userAuthenticated;
  16.    
  17.    private IdCard id;
  18.    private Kendaraan vec;
  19.    private BuktiBayar pay;
  20.    private Scanner input;
  21.    private Database data;
  22.    
  23.    
  24.    public Transaction(){
  25.     biayaTol=0;
  26.     input = new Scanner(System.in);
  27.     pengendara="Taufiq";
  28.     userAuthenticated=false;
  29.     vechileAuthenticated=false;
  30.     }
  31.    
  32.    public void bayarTol(){
  33.        System.out.print("selamat datang, ");
  34.        pengendara=getInput();
  35.        System.out.print("!");
  36.        
  37.        userAuthenticated = data.authenticateUser(pengendara);
  38.        if(userAuthenticated){
  39.            id=data.getAccount(pengendara);
  40.            biayaTol=getKendaraan();
  41.            if(id.saldo>=biayaTol){
  42.                 //pintu terbuka
  43.                 pay.tampilkanBuktiBayar();
  44.                 id.saldo-=biayaTol;
  45.             }
  46.            
  47.            else{
  48.                //pintu tertutup
  49.                 System.out.println("saldo tidak mencukupi");
  50.             }
  51.        }
  52.     }
  53.    
  54.    public int getKendaraan(){
  55.        
  56.        
  57.        vechileAuthenticated=data.authenticateVec(pengendara);
  58.        if(vechileAuthenticated){
  59.             vec=data.getVec(pengendara);
  60.            
  61.             if(vec.jenisKendaraan=="GOLONGAN1"){
  62.                 biayaTol=2000;
  63.             }
  64.             else if(vec.jenisKendaraan=="GOLONGAN2"){
  65.                 biayaTol=3000;
  66.             }
  67.             else{
  68.                 biayaTol=4000;
  69.             }
  70.         }
  71.        
  72.        return biayaTol;
  73.      }
  74.    
  75.    public String getInput(){
  76.        return input.nextLine();
  77.     }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment