# Mini-bank **Repository Path**: yuangran/mini-bank ## Basic Information - **Project Name**: Mini-bank - **Description**: No description available - **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-11 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Mini-bank This is a simple C++ mini banking system designed to simulate basic banking operations such as account management, deposits, withdrawals, transfers, customer management, transaction recording, and report generation. The system is designed using object-oriented principles, with classes and inheritance mechanisms to manage different types of bank accounts. ## Individual messages - Chinese name:虞盎然 - Engilsh name:Terry - ID:2023900899 ## Features 1. **Customer Management** - Register new customers and create both a savings and a checking account for them. - Search for customers by name. 2. **Account Management** - Each customer can have both a savings account and a checking account. - Perform actions such as checking account balance, deposit, withdrawal, and transfer. 3. **Transaction Recording** - Every deposit, withdrawal, and transfer generates a transaction record and is saved to the account's transaction history. - View the transaction history of an account. 4. **Report Generation** - Generate a transaction report for all customers and save it to a file. - Generate a customer-specific report, including account balances and transaction history. 5. **Simple Menu-Driven System** - The system provides a command-line menu interface for interacting with the system, where users can choose different options like customer registration, account access, viewing accounts, generating reports, etc. ## Architecture The system is structured into the following major components: 1. **Account Class** - A base class that holds account information like account ID, balance, account holder, and transaction history. 2. **CheckingAccount Class** - A subclass of `Account`, representing a checking account, providing deposit and withdrawal methods. 3. **SavingsAccount Class** - A subclass of `Account`, representing a savings account, which does not allow deposit or withdrawal but supports transfers. 4. **Customer Class** - Represents a bank customer, holding a checking account and a savings account. 5. **Bank Class** - Manages all customers and their accounts. 6. **Transaction Class** - Records the details of each transaction. 7. **Menu Class** - Provides the user interface and handles user input for various operations. ### Class Descriptions #### 1. **Account Class** - **Attributes**: - `accountId`: The unique account ID. - `balance`: The account balance. - `accountHolder`: The name of the account holder. - `transactions`: A vector of strings that stores transaction records. - **Methods**: - `getAccountId()`: Returns the account ID. - `getBalance()`: Returns the account balance. - `showBalance()`: Returns the balance as a formatted string. - `getAccountHolder()`: Returns the account holder's name. - `getTransactions()`: Returns all transactions. - `deposit()`: Pure virtual function for deposit. - `withdraw()`: Pure virtual function for withdrawal. - `transfer()`: Transfers money to another account. - `recordTransaction()`: Records a transaction. #### 2. **CheckingAccount Class** (Inherits from `Account`) - **Methods**: - `deposit()`: Deposits a certain amount into the checking account. - `withdraw()`: Withdraws a certain amount from the checking account. - `showinfo()`: Displays account information. - `generateAccountID()`: Generates a random checking account ID. #### 3. **SavingsAccount Class** (Inherits from `Account`) - **Methods**: - `showinfo()`: Displays account information. - `generateAccountID()`: Generates a random savings account ID. #### 4. **Customer Class** - **Attributes**: - `name`: Customer's name. - `checkingAccount`: Pointer to the customer's checking account. - `savingsAccount`: Pointer to the customer's savings account. - **Methods**: - `getName()`: Returns the customer's name. - `getCheckingAccount()`: Returns the checking account. - `getSavingsAccount()`: Returns the savings account. - `getTransactions()`: Returns all transactions from both accounts. #### 5. **Bank Class** - **Attributes**: - `customers`: A vector of pointers to customers. - `existingAccountIds`: A set of existing account IDs to ensure uniqueness. - **Methods**: - `addCustomer()`: Adds a new customer. - `findCustomer()`: Finds a customer by name. - `showAllAccounts()`: Displays all accounts. - `findAccountById()`: Finds an account by its ID. - `checkCustomerName()`: Checks if a customer name already exists. - `checkAccountId()`: Checks if an account ID already exists. #### 6. **Transaction Class** - **Attributes**: - `transactionId`: The unique ID for the transaction. - `amount`: The amount involved in the transaction. - `transactionType`: Type of transaction (Deposit, Withdraw, Transfer). - `note`: An optional note for the transaction. - **Methods**: - `displayTransaction()`: Displays the transaction details. #### 7. **Menu Class** - **Methods**: - `showMainMenu()`: Displays the main menu. - `registerCustomer()`: Registers a new customer. - `accessCustomerAccounts()`: Allows access to a customer's accounts. - `generateTransactionReport()`: Generates a transaction report for all customers. - `viewTransactions()`: Displays all transactions for a customer. - `generateCustomerReport()`: Generates a report for a specific customer. - `accessAccount()`: Allows access to a specific account (either checking or savings). - `depositToAccount()`: Handles deposit functionality. - `withdrawFromAccount()`: Handles withdrawal functionality. - `transferFromAccount()`: Handles transfer functionality. - `viewTransactionHistory()`: Displays the transaction history of an account. ## Compilation and Execution ### 1. Compile the Code Ensure you have a C++ compiler (like `g++`) installed. In the terminal, navigate to the project directory and run the following command to compile the program: ``` g++ -o bank_system main.cpp src/*.cpp -std=c++11 ``` ### 2. Run the Program Once the compilation is complete, run the program by executing the following command: ``` ./mini-bank ```