import javax.swing.*;
/** This is a bank account for our customer 
 */
public class BankAccount {
/** name of the account owner */
  private String name ;
/** bank balance for this account */  
  private double balance;
/** create a bank account and prompt for owner's name.
 */
  public BankAccount() {
  this.name =  JOptionPane.showInputDialog("Please enter bank account owner's name");
  }

  /** create a bank account using an initial balance amt and prompt for
   *  owner's name.
   */
  public BankAccount(double amt) {
    this.balance = amt;
    this.name =  JOptionPane.showInputDialog("Please enter bank account owner's name");
  }
  
  /** create a bank account using the owner's name n and initialize
   *  the bank balance to $50.00.
   */
  public BankAccount(String n) {
    this.balance = 50.00;
    this.name = n;
  }
  
  /** create a bank account using the owner's name n and starting
   *   balance amt.
   */
    public BankAccount(String n, double amt) {
    this.balance = amt;
    this.name = n;
  }

  /** Verifies whether the balance is greater than or equal to amount a.
   *  Returns true if it is, otherwise it returns false.
   */
  public boolean verifyAmount(double a) {
    return this.balance >= a;
  }
  
  /** this method withdraws amount a from the 
   *  balance and returns the new balance
   */
  public double withdraw(double a) {
    balance = balance - a;
    return this.balance;
  }
  
  /** adds the name to the BankAccount */
  public void setName(String n) {
    this.name = n;
  }
  
  /** return the BankAccount owner's  name */
  public String getName(){
    return this.name;
  }
  
  /** get the bank account balance */
    public double getBalance() {
    return this.balance;
  }

  /** deposit amount a into Bankaccount
   *  and return the new balance 
   */
  public double deposit(double b) {
    balance += b;
    return this.balance;
    
  }
  /** calculates principle interest at the rate  r given.
   */
  public double calcInterest(double r) {
    this.balance += (this.balance * r);
    return this.balance;
  }
  
  /** returns name and amount in a single string. */
  public String getNameAmt() {
    /* Note: we cannot concatenate "+" a double to the string we are 
     *      constructing.  We must use the static method Double.toString(double d)
     *      to convert our double value to a string.  The class name is always
     *      included in a static method invocation.
     */
    return this.getName() + " " + Double.toString(this.getBalance());
  }
}

