Class CurrentAccount

java.lang.Object
bank.account.CurrentAccount
All Implemented Interfaces:
Serializable

public class CurrentAccount extends Object
Class for current accounts. These accounts allow withdrawals that do not exceed the current balance. Current accounts have 0% (zero) interest rates.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    CurrentAccount(int number, double amount)
    Initialize a current account, setting the initial balance.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    addBalance(double amount)
    Add to the current balance (protected!).
    void
    deposit(double amount)
    Add the given amount to the current balance (if the amount is positive).
    final boolean
     
    double
    Returns the current balance.
    final LocalDate
    Returns the date of the deposit.
    final int
    Return the deposit account number.
    final double
    Return the account rate.
     
    void
    withdraw(double amount)
    Withdraw a given amount: the balance must be grater or equal to the amount to be withdrawn.

    Methods inherited from class Object

    clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • CurrentAccount

      public CurrentAccount(int number, double amount)
      Initialize a current account, setting the initial balance.
      Parameters:
      number - the account number.
      amount - the initial balance.
  • Method Details

    • deposit

      public void deposit(double amount) throws NegativeAmountException
      Add the given amount to the current balance (if the amount is positive).
      Parameters:
      amount - the amount to be deposited.
      Throws:
      NegativeAmountException - if the amount is not positive.
    • withdraw

      public void withdraw(double amount) throws NegativeAmountException, BalanceTooLowException
      Withdraw a given amount: the balance must be grater or equal to the amount to be withdrawn.
      Parameters:
      amount - the amount to be withdrawn.
      Throws:
      NegativeAmountException
      BalanceTooLowException
    • toString

      public String toString()
      Overrides:
      toString in class Object
      See Also:
    • addBalance

      protected void addBalance(double amount)
      Add to the current balance (protected!).
      Parameters:
      amount - the amount to increase (or decrease).
    • getBalance

      public double getBalance()
      Returns the current balance.
      Returns:
      the current balance.
    • getCreationDate

      public final LocalDate getCreationDate()
      Returns the date of the deposit.
      Returns:
      the date of the deposit.
    • getRate

      public final double getRate()
      Return the account rate.
      Returns:
      the account rate
    • getNumber

      public final int getNumber()
      Return the deposit account number.
      Returns:
      the deposit account number
    • equals

      public final boolean equals(Object o)
      Overrides:
      equals in class Object
      See Also: