Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Toll
- {
- private boolean userAuthenticated;
- private int currentAccountNumber;
- private TollDatabase tollDatabase;
- Scanner input = new Scanner(System.in);
- public Toll()
- {
- userAuthenticated = false;
- currentAccountNumber = 0;
- tollDatabase = new TollDatabase();
- }
- public void run()
- {
- while(true)
- {
- while(!userAuthenticated)
- {
- System.out.print("\nWelcome!");
- AuthenticateUser();
- }
- Transaction cash = null;
- cash = new CashCheck(currentAccountNumber, tollDatabase);
- cash.execute();
- userAuthenticated = false;
- currentAccountNumber = 0;
- System.out.print("\nThank You! Come Again!");
- }
- }
- private void AuthenticateUser()
- {
- System.out.print("\nPlease enter your account number: ");
- int accountNumber = input.nextInt();;
- System.out.print("\nPlease enter your PIN: ");
- int pin = input.nextInt();;
- userAuthenticated = tollDatabase.authenticateUser(accountNumber, pin);
- if(userAuthenticated)
- {
- currentAccountNumber = accountNumber;
- }
- else System.out.print("\nInvalid account or PIN. Please try again");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement