//Written by Joseph King
//St Stanislaus College - Bathurst
//18.10.01

public class Atm
  { 
  public static void main (String [] args)
    { 

// Create new account

    BankAccount Acc1 = new BankAccount();
    KeyboardReader kb = new KeyboardReader();
    double Deposit;
    double Withdrawal;

    System.out.print("Please enter the name of the person who is opening the account:");   
    String AccountName = kb.getString();
    Acc1.setName(AccountName);

// Acc1

// Output Name and Balance
    System.out.println("The owner of this account is " + Acc1.getName());
    System.out.println("The current balance of this acount is " + Acc1.getBalance());

// interactive deposit

      do
      {
      System.out.println("Please enter the amount you wish to deposit.");
      Deposit = kb.getDouble();
      if (Deposit <= 0)
        System.out.println("Please enter a positive amount.");
      }
    while (Deposit <= 0);
      System.out.println("The balance before the deposit was $" + Acc1.getBalance());
      Acc1.deposit(Deposit);
      System.out.println("The balance after the deposit of $" + Deposit + " is $" + Acc1.getBalance());
     
      do
      { 
      System.out.println("Please enter the amount you wish to withdrawal.");
      System.out.println("Note: This account has a current balance of $" + Acc1.getBalance());
      Withdrawal = kb.getDouble();
      if (Acc1.getBalance() <= 0)
        System.out.println("Sorry you have no money in your account to withdrawal.");
      else
        { 
        if (Withdrawal <= 0)
          System.out.println("Cannot issue a negative amount.");
        else
          if (Withdrawal > Acc1.getBalance())
            System.out.println("Insufficient funds in account.");
        } 
      } 
      while ((Withdrawal > Acc1.getBalance()) || (Withdrawal <= 0));
      System.out.println("The balance before the withdrawal was $" + Acc1.getBalance());
      Acc1.withdrawal(Withdrawal);
      System.out.println("The balance after the withdarwal of $" + Withdrawal + " is $"+Acc1.getBalance());

    } 
}
