# bank **Repository Path**: hw__2004/bank ## Basic Information - **Project Name**: bank - **Description**: bank simulation - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-05-07 - **Last Updated**: 2025-05-12 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # bank wren(何唯)id:2023905416 #### intrduce ### 1. Class Documentation ## 1.1 IAccount (Interface) Description: Abstract base class defining common banking account operations. Attributes: accountId (string): Unique account identifier. balance (double): Current account balance. transactions (vector): List of transactions. Methods: virtual bool deposit(double amount) = 0: Deposits funds (implemented only in CheckingAccount). virtual bool withdraw(double amount) = 0: Withdraws funds (implemented only in CheckingAccount). virtual bool transfer(IAccount& target, double amount) = 0: Transfers funds between accounts. virtual std::string getAccountId() const = 0: Returns the account ID. virtual void addTransaction(const Transaction& transaction) = 0: Adds a transaction record. ## 1.2 CheckingAccount Inherits: IAccount Description: Represents a checking account allowing deposits, withdrawals, and transfers. Methods: bool deposit(double amount) override: Adds funds to the account. bool withdraw(double amount) override: Deducts funds from the account. bool transfer(IAccount& target, double amount) override: Transfers funds to any valid account. void forceDeposit(double amount): Directly modifies balance (bypassing deposit logic). ## 1.3 SavingsAccount Inherits: IAccount Description: Represents a savings account with restricted operations. Methods: bool transfer(IAccount& target, double amount) override: Transfers funds only to the same customer’s checking account. bool deposit(double amount) override: Always returns false (disabled). bool withdraw(double amount) override: Always returns false (disabled). ## 1.4 Customer Description: Manages a customer’s savings and checking accounts. Attributes: name (string): Customer’s name. savingsAccount (SavingsAccount): Savings account object. checkingAccount (CheckingAccount): Checking account object. Methods: IAccount* getSavingsAccount(): Returns the savings account. IAccount* getCheckingAccount(): Returns the checking account. void displayAllTransactions(): Shows all transactions across accounts. ## 1.5 Transaction Description: Records details of financial transactions. Attributes: type (enum: DEPOSIT, WITHDRAW, TRANSFER): Transaction type. amount (double): Transaction amount. timestamp (string): Time of transaction. fromAccountId (string): Source account ID. toAccountId (string): Destination account ID. Methods: void display() const: Prints transaction details. ## 1.6 UserInterface Description: Handles user interactions and menu navigation. Methods: void run(): Starts the application loop. void createCustomer(): Registers a new customer. void handleTransfer(IAccount* sourceAccount): Manages transfer logic. ### 2. Architecture Explanation The system follows an object-oriented design with layered components: Interface Layer: IAccount enforces polymorphism for account types. UserInterface handles input/output and menu navigation. Business Logic Layer: CheckingAccount and SavingsAccount implement account-specific operations. Customer aggregates accounts and transaction history. Data Layer: Transaction stores transaction data. AccountManager generates unique account IDs. Key Design Principles: Encapsulation: Account balances and transactions are accessed/modified via methods only. Inheritance: CheckingAccount and SavingsAccount derive from IAccount. Separation of Concerns: UI logic is decoupled from business logic. ### 3. Compilation and Execution Guide ## 3.1 Compilation (Using g++) Install Dependencies: Ensure g++ and make are installed. ## Compile Code: # First: cd sources # Second: g++ AccountManager.cpp CheckingAccount.cpp Customer.cpp main.cpp SavingsAccount.cpp Transaction.cpp UserInterface.cpp utils.cpp -o bank_system.exe # Third(run the project): ./bank_system.exe # Menu Options: 1. Register New Customer: Enter a name to create accounts. 2. Access Customer Accounts: View/modify accounts by name. 5. Exit: Exit the system. # 3.3 Testing Key Features Deposit/Withdraw: Only available for checking accounts. Transfer: Checking → Any account. Savings → Same customer’s checking account only. Reports: Generate transaction reports via the main menu.