Package entity
Class SavingsAccount
java.lang.Object
entity.AbstractAccount
entity.SavingsAccount
Represents a savings account with a minimum balance constraint.
Extends the
AbstractAccount
class.- Author:
- TAMIL
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsFields inherited from class entity.AbstractAccount
accountNo, accountType, balance, customerId
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
canWithdraw
(BigDecimal amount) Checks if withdrawal is allowed, enforcing minimum balance.int
Gets the branch ID where the account is held.toString()
Methods inherited from class entity.AbstractAccount
deposit, getAccountNo, getAccountType, getBalance, getCustomerId, isValidAccount, setBalance, withdraw
-
Field Details
-
branch_id
private final int branch_id -
MIN_BALANCE
-
-
Constructor Details
-
SavingsAccount
-
-
Method Details
-
getBranchId
public int getBranchId()Gets the branch ID where the account is held.- Specified by:
getBranchId
in classAbstractAccount
- Returns:
- the branch ID
-
canWithdraw
Checks if withdrawal is allowed, enforcing minimum balance.- Overrides:
canWithdraw
in classAbstractAccount
- Parameters:
amount
- amount to withdraw- Returns:
true
if withdrawal is allowed;false
otherwise
-
toString
-