package account;

public class Account {
  private String name; // name of person
  private String number; // account number
  private double beginningBalance; // balance at start of month
  private double currentBalance; // current balance
  private double depositsThisMonth;
  private double withdrawalsThisMonth;
  public Account(String name, String number) {
    this.name = name;
    beginningBalance = 0;
    this.number = number;
    currentBalance = 0;
    depositsThisMonth = 0;
    withdrawalsThisMonth = 0;
  }
  public String toString() {
    String result = "Account " + number + " for "
        + name;
    result += "\nBeginning Balance = " +
        beginningBalance;
    result += "\nDeposits This Month = " +
        depositsThisMonth;
    result += "\nWithdrawals this month = " +
        withdrawalsThisMonth;
    result += "\nCurrent balance = " + currentBalance;
    return result;
  }
  // return true if deposit was successful
  public boolean deposit(double amount) {
    if (amount <= 0) {
      return false;
    } else {
      depositsThisMonth += amount;
      currentBalance += amount;
      return true;
    }
  }
  // returns true if withdrawal was successful
  public boolean withdrawal(double amount) {
    if (amount <= 0) return false;
    if (amount > currentBalance) return false;
    withdrawalsThisMonth += amount;
    currentBalance -= amount;
    return true;
  }
  public void endOfMonth() {
    beginningBalance = currentBalance;
    depositsThisMonth = 0;
    withdrawalsThisMonth = 0;
  }
}





