Package bank.accounts

Class Current

java.lang.Object
bank.accounts.Current
All Implemented Interfaces:
Serializable

public class Current 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:
Serialized Form
  • Constructor Summary

    Constructors
    Constructor
    Description
    Current​(int id, 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).
    boolean
    equals​(Object depacc)
     
    double
    Returns the current balance.
    long
    Returns the date of the deposit.
    int
    Return the deposit account id.
    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 java.lang.Object

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

    • Current

      public Current(int id, double amount)
      Initialize a current account, setting the initial balance.
      Parameters:
      id - the account id.
      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:
      Object.toString()
    • 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 long 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
    • getId

      public final int getId()
      Return the deposit account id.
      Returns:
      the deposit account id
    • equals

      public final boolean equals(Object depacc)
      Overrides:
      equals in class Object
      See Also:
      Object.equals(java.lang.Object)