import java.util.Scanner;

/**
 * Bank class with Teller
 * @author your_name_here
 * @version 0.1
 */

public class Bank {
	
	/* Variables */
	
	
	
	/* Constructors */
	
	
	/**	
	 * Default constructor
	 */
	public Bank (){
		System.out.println("Bank created");
	}
	
	/* Methods */
	
	/**
	 *  Teller that runs bank commands
	 *  
	 */
	public void Teller() {
		
		System.out.println("Welcome to the Teller");
		
		Scanner scan = new Scanner(System.in);
		
		BankAccount acct1 = new BankAccount(0.00);
		
		while (true) {
			
			/* Check for replies */		
			
			System.out.println("");
			System.out.println("=== LIST OF COMMANDS ===");
			System.out.println("b = get balance");
			System.out.println("d = deposit");
			System.out.println("w = withdraw");
			System.out.println("q = quit");
			System.out.println("Enter a command: ");

			String reply = scan.nextLine();
			
			
			if(reply.equalsIgnoreCase("b")) {
				acct1.printBalance("Balance =", ".");
			}
			
			else if (reply.equalsIgnoreCase("d")) {
				System.out.println("Enter Deposit Amount = ");
				reply = scan.nextLine();
				Scanner scanstr = new Scanner(reply);
				if (scanstr.hasNextDouble())
					acct1.deposit(scanstr.nextDouble());
				else
					System.out.println("Not valid. Start over");
			}
			
			else if (reply.equalsIgnoreCase("w")) {
				System.out.println("Enter Withdrawal Amount = ");
				reply = scan.nextLine();
				Scanner scanstr = new Scanner(reply);
				if (scanstr.hasNextDouble())
					acct1.withdraw(scanstr.nextDouble());
				else
					System.out.println("Not a valid number. Start over");
			}
			
			else if (reply.equalsIgnoreCase("q")) {
				return;
			}			
			
			else {
				System.out.println("Invalid reply. Try again");
			}
		}
	}
	
}
