Package entity

Class AbstractAccount

java.lang.Object
entity.AbstractAccount
Direct Known Subclasses:
SavingsAccount

public abstract class AbstractAccount extends Object
Represents an abstract bank account with basic operations like deposit and withdrawal. Serves as a base class for specific account types like SavingsAccount.
Author:
TAMIL MUGHILAN
See Also:
  • Field Details

    • accountNo

      protected int accountNo
    • customerId

      protected int customerId
    • balance

      protected BigDecimal balance
    • accountType

      protected String accountType
  • Constructor Details

    • AbstractAccount

      protected AbstractAccount(int accountNo, int customerId, BigDecimal balance, String accountType)
      Constructs an AbstractAccount.
      Parameters:
      accountNo - account number
      customerId - customer ID
      balance - initial balance
      accountType - type of account (e.g., "Savings")
  • Method Details

    • getBranchId

      public abstract int getBranchId()
      Gets the branch ID where the account is held.
      Returns:
      the branch ID
    • canWithdraw

      public boolean canWithdraw(BigDecimal amount)
      Checks if a withdrawal of the given amount is allowed.
      Parameters:
      amount - amount to withdraw
      Returns:
      true if withdrawal is allowed; false otherwise
    • withdraw

      public boolean withdraw(BigDecimal amount)
      Attempts to withdraw the given amount from the account.
      Parameters:
      amount - amount to withdraw
      Returns:
      true if withdrawal successful; false otherwise
    • deposit

      public void deposit(BigDecimal amount)
      Deposits the given amount to the account.
      Parameters:
      amount - amount to deposit
    • isValidAccount

      public boolean isValidAccount()
      Validates the account details.
      Returns:
      true if the account is valid; false otherwise
    • getAccountNo

      public int getAccountNo()
      Gets the account number.
      Returns:
      the account number
    • getCustomerId

      public int getCustomerId()
      Gets the customer ID.
      Returns:
      the customer ID
    • getBalance

      public BigDecimal getBalance()
      Gets the account balance.
      Returns:
      the current balance
    • getAccountType

      public String getAccountType()
      Gets the account type.
      Returns:
      the account type
    • setBalance

      public void setBalance(BigDecimal balance)
      Sets the account balance.
      Parameters:
      balance - the new balance