Package bank.accounts
Class Current
java.lang.Object
bank.accounts.Current
- 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:
- Serialized Form
-
Constructor Summary
ConstructorsConstructorDescriptionCurrent(int id, 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).booleandoubleReturns the current balance.longReturns the date of the deposit.intgetId()Return the deposit account id.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
-
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
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
- Overrides:
toStringin classObject- 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
- Overrides:
equalsin classObject- See Also:
Object.equals(java.lang.Object)
-