Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Write a description of class Transaction here.
- *
- * @author (your name)
- * @version (a version number or a date)
- */
- import java.util.Scanner;
- public class Transaction
- {
- int biayaTol;
- int currentMoney;
- String pengendara;
- private boolean vechileAuthenticated;
- private boolean userAuthenticated;
- private IdCard id;
- private Kendaraan vec;
- private BuktiBayar pay;
- private Scanner input;
- private Database data;
- public Transaction(){
- biayaTol=0;
- input = new Scanner(System.in);
- pengendara="Taufiq";
- userAuthenticated=false;
- vechileAuthenticated=false;
- }
- public void bayarTol(){
- System.out.print("selamat datang, ");
- pengendara=getInput();
- System.out.print("!");
- userAuthenticated = data.authenticateUser(pengendara);
- if(userAuthenticated){
- id=data.getAccount(pengendara);
- biayaTol=getKendaraan();
- if(id.saldo>=biayaTol){
- //pintu terbuka
- pay.tampilkanBuktiBayar();
- id.saldo-=biayaTol;
- }
- else{
- //pintu tertutup
- System.out.println("saldo tidak mencukupi");
- }
- }
- }
- public int getKendaraan(){
- vechileAuthenticated=data.authenticateVec(pengendara);
- if(vechileAuthenticated){
- vec=data.getVec(pengendara);
- if(vec.jenisKendaraan=="GOLONGAN1"){
- biayaTol=2000;
- }
- else if(vec.jenisKendaraan=="GOLONGAN2"){
- biayaTol=3000;
- }
- else{
- biayaTol=4000;
- }
- }
- return biayaTol;
- }
- public String getInput(){
- return input.nextLine();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment