How syedzubyl/access-modifiers works
Purpose and Runtime
A framework-free Core Java console banking system designed around OOP, encapsulation, inheritance, and access-modifier boundaries. It compiles to JVM bytecode and runs through app.Main with no web tier, persistence server, or external service dependency. Entry point: src/app/Main.java.
Application Orchestration
Main starts the application and delegates interactive console behavior to the service layer. BankService owns menu-driven use cases such as account creation, authentication, balance operations, and user-input error handling; it is the primary boundary between console I/O and domain objects.
• src/app/Main.java
• src/bank/service/BankService.java
In-Memory Repository Boundary
BankDatabase is the system’s in-memory state holder. It maps account numbers to Account instances for direct lookup and maintains customers in a collection. All data is process-local: application restart loses accounts, customers, balances, and histories.
• src/bank/database/BankDatabase.java
• src/bank/customer/Customer.java
Account Domain and Polymorphic Withdrawal
Account is the abstract core aggregate: it associates account identity, customer, balance, PIN protection, and transaction history. Its subclasses implement different withdrawal rules while sharing common account behavior. SavingsAccount enforces a minimum-balance policy; CurrentAccount provides its own overdraft-oriented behavior. Protected balance mutation permits subclasses to apply those rules without exposing arbitrary balance writes to services.
• src/bank/account/Account.java
• src/bank/account/SavingsAccount.java
• src/bank/account/CurrentAccount.java
Security and Validation Boundaries
PIN state is isolated in PinManager; callers authenticate through verification rather than direct PIN access. Input/domain validation is centralized in static utilities, while account-internal validation remains package-scoped to the account package. This separates service-level user interaction from protected domain state.
• src/bank/security/PinManager.java
• src/bank/util/Validation.java
• src/bank/account/Account.java
Transaction Recording Flow
Deposits and withdrawals are represented as transaction types and collected by TransactionHistory associated with an account. A successful service operation flows from input parsing → account lookup/authentication → account deposit/withdraw policy → transaction-history update. Failed withdrawals surface as checked domain exceptions rather than silently altering state.
• src/bank/transaction/Deposit.java
• src/bank/transaction/Withdraw.java
• src/bank/transaction/TransactionHistory.java
Failure Model
The domain uses checked exceptions to force explicit handling of invalid credentials and insufficient funds. BankService also handles malformed console numeric input, preventing invalid user input from terminating the process.
• src/bank/exception/InvalidPinException.java
• src/bank/exception/InsufficientBalanceException.java
• src/bank/service/BankService.java
Main entry points: Account.java Account · BankService.java BankService · BankDatabase.java BankDatabase · TransactionHistory.java TransactionHistory
Components 14
Runtime
- Main
src/app/Main.java
Application Service
- BankService · Owns menus, input handling, and banking workflows.
src/bank/service/BankService.java
Bank Domain
- Customer
src/bank/customer/Customer.java - Account · Holds identity, customer, balance, PIN protection, and history.
src/bank/account/Account.java - SavingsAccount · Applies a minimum-balance withdrawal policy.
src/bank/account/SavingsAccount.java - CurrentAccount · Applies overdraft-oriented withdrawal behavior.
src/bank/account/CurrentAccount.java - Deposit
src/bank/transaction/Deposit.java - Withdraw
src/bank/transaction/Withdraw.java - TransactionHistory · Collects account deposit and withdrawal records.
src/bank/transaction/TransactionHistory.java - InsufficientBalanceException
src/bank/exception/InsufficientBalanceException.java
In-Memory State
- BankDatabase · Process-local account and customer state.
src/bank/database/BankDatabase.java
Security & Validation
- PinManager · Verifies PINs without exposing PIN state.
src/bank/security/PinManager.java - Validation
src/bank/util/Validation.java - InvalidPinException
src/bank/exception/InvalidPinException.java
Connections 19
- Main → BankService: starts
- BankService → BankDatabase: looks up accounts
- BankService → Validation: validates input
- BankService → Account: authenticates and operates
- BankDatabase → Account: maps account number to
- BankDatabase → Customer: stores
- Account → Customer: belongs to
- SavingsAccount → Account: extends
- CurrentAccount → Account: extends
- Account → PinManager: delegates PIN verification
- Account → TransactionHistory: owns
- Deposit → TransactionHistory: recorded in
- Withdraw → TransactionHistory: recorded in
- Account → Deposit: creates on deposit
- Account → Withdraw: creates on successful withdrawal
- PinManager → InvalidPinException: throws
- Account → InsufficientBalanceException: throws on failed withdrawal
- BankService → InvalidPinException: handles
- BankService → InsufficientBalanceException: handles