# divid **Repository Path**: divid123/divid ## Basic Information - **Project Name**: divid - **Description**: No description available - **Primary Language**: Unknown - **License**: MulanPSL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-05-10 - **Last Updated**: 2025-05-11 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # MiniBankingSystem ## Student Information - **Chinese Name**: 高圣煜 - **Student ID**: 2023901566 - **English Name**:Divid --- ## Project Overview MiniBankingSystem is a C++ console application that simulates a small-scale banking system, supporting customer management, account operations, transaction processing, and report generation. The project aims to reinforce understanding of interfaces, inheritance, function and operator overloading, classes, structs, multi-file organization, headers, and namespaces. --- ## Features - **Customer Management**: Register new customers with automatic creation of savings and checking accounts. - **Account Operations**: Support deposits, withdrawals, and transfers (with account type restrictions). - **Transaction Recording**: Automatically record transactions and generate reports. - **Report Generation**: Provide global, customer-specific, and account-specific transaction reports. - **User Interface**: Menu-driven console interface for user interaction. --- ## Class Structure ### Account (Abstract Base Class) - **Attributes**: - `accountID`: Account identifier - `ownerName`: Account holder's name - `balance`: Account balance - `transactions`: List of transaction records - **Methods**: - Pure virtual: `canDeposit()`, `canWithdraw()`, `canTransferTo()` - Common: `getAccountID()`, `getOwnerName()`, `getBalance()`, `getTransactions()`, `deposit()`, `withdraw()`, `transfer()`, `addTransaction()` ### SavingsAccount (Derived from Account) - **Methods**: - Overrides: `canDeposit()`, `canWithdraw()`, `canTransferTo()` ### CheckingAccount (Derived from Account) - **Methods**: - Overrides: `canDeposit()`, `canWithdraw()`, `canTransferTo()` ### Transaction - **Attributes**: - `transactionID`: Transaction identifier - `accountID`: Associated account identifier - `amount`: Transaction amount - `type`: Transaction type - `note`: Transaction note - `timestamp`: Transaction timestamp - **Methods**: - `getTransactionID()`, `getAccountID()`, `getAmount()`, `getType()`, `getNote()`, `getTimestamp()` ### Customer - **Attributes**: - `name`: Customer name - `savingsAccount`: Savings account - `checkingAccount`: Checking account - **Methods**: - `getName()`, `getSavingsAccount()`, `getCheckingAccount()` ### Bank - **Attributes**: - `customers`: List of customers - `accounts`: List of accounts - `rng`: Random number generator - **Methods**: - `addCustomer()`, `getCustomer()`, `getAccount()`, `displayAllAccounts()`, `generateGlobalTransactionReport()`, `generateCustomerReport()`, `generateAccountReport()` ### UI - **Attributes**: - `bank`: Reference to the bank object - **Methods**: - `run()`, `handleRegisterCustomer()`, `handleAccessCustomer()`, `handleCustomerMenu()`, `handleAccountMenu()`, `displayTransactions()` --- ## Architecture - **Single Responsibility Principle**: Each class is designed to handle specific functionalities. - **Inheritance**: `SavingsAccount` and `CheckingAccount` inherit from the `Account` base class. - **Encapsulation**: Data members are private, with public methods for access and manipulation. - **Namespace**: All classes are organized under the `BankingSystem` namespace to avoid naming conflicts. - **Smart Pointers**: `unique_ptr` is used for managing `Customer` and `Account` objects to ensure proper resource management. - **Multi-file Organization**: Each class has its own header (.h) and implementation (.cpp) files for clarity and maintainability. --- ## Design Decisions 1. **Memory Management**: Utilized `unique_ptr` for automatic resource management of `Customer` and `Account` objects. 2. **Interface Design**: Employed pure virtual functions in `Account` to enforce specific behaviors in derived classes. 3. **Data Structures**: Used `std::map` for efficient lookup of customers and accounts. 4. **Account ID Generation**: Implemented random generation of account IDs with uniqueness checks. 5. **Transaction Handling**: Transactions are sorted chronologically for easy reporting. 6. **Error Handling**: Added input validation and exception handling to enhance robustness. 7. **User Experience**: Implemented platform-independent screen clearing for a better console interface. --- ## Compilation and Execution ### Using CMake (Recommended) 1. Create a build directory: ```bash mkdir build && cd build ``` 2. Configure CMake: ```bash cmake .. ``` 3. Build the project: ```bash cmake --build . ``` 4. Run the program: ```bash ./bin/banking_system # Linux/macOS bin\banking_system.exe # Windows ``` ### Using g++ Directly ```bash g++ -std=c++17 -Iinclude src/*.cpp -o banking_system ``` ## Running the Program ```bash ./banking_system # Linux/macOS banking_system.exe # Windows ``` Follow the menu prompts to: 1. Register new customers 2. Access customer accounts 3. View all accounts 4. Generate transaction reports 5. Exit --- ### Notes - **Student Information**: Please replace the placeholders with your actual student ID and English name. - **Architecture and Design**: The document provides a detailed explanation of the class structure, architecture, and key design decisions. - **Compilation and Execution**: Both CMake and direct g++ compilation methods are provided for flexibility.