Class CurrentAccount
java.lang.Object
bank.account.CurrentAccount
- All Implemented Interfaces:
Serializable
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
ConstructorsConstructorDescriptionCurrentAccount(int number, double amount) Initialize a current account, setting the initial balance. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddBalance(double amount) Add to the current balance (protected!).voiddeposit(double amount) Add the given amount to the current balance (if the amount is positive).final booleandoubleReturns the current balance.final LocalDateReturns the date of the deposit.final intReturn the deposit account number.final doublegetRate()Return the account rate.toString()voidwithdraw(double amount) Withdraw a given amount: the balance must be grater or equal to the amount to be withdrawn.
-
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
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
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:
NegativeAmountExceptionBalanceTooLowException
-
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
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
-