# tracy **Repository Path**: Tracyyyds/tracy ## Basic Information - **Project Name**: tracy - **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-04-24 - **Last Updated**: 2025-05-12 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # tracy tracy 高祎欣 2023905331 ### Instructions on how to compile and run the program Please pay special attention!!!!!!!!!! Please pay special attention!!!!!!!!!! Please pay special attention!!!!!!!!!! You will have two options to run the program. First, because I wrote this code and program using Visual Studio 2022. If you have this software, you can open the folder 'Personal project11' in Visual Studio 2022 and run it successfully.Open the project1 folder, and you will see the complete code. Secondly, I have also uploaded the version folder of the Personal project22 that can run with Visual Studio code. It contains a program description that uses CMake, which I have written below for your convenience. Personal project22/![输入图片说明](image.png) └── 个人作业22/ └── 新建文件夹 (4)/ ├── CMakeLists.txt ├── src/ │ ├── Account.cpp │ ├── Account.h │ ├── Bank.cpp │ ├── Bank.h │ ├── main.cpp │ └── ... (Other source files) ├── include/ │ └── ... (Header file) ├── build/ │ ├── CMakeCache.txt │ ├── Makefile │ ├── cpp_project.exe (The executable file generated after compilation) │ └── ... (Files generated by other builds) └── .gitignore # Enter the project root directory cd Personal project22/个人作业22/新建文件夹 (4) # Create and enter the build directory mkdir build cd build # Generate build files using CMake cmake .. # Compiling project mingw32-make # Run the program ./cpp_project ### **Project MiniBanking System report** ### 一.Documentation that describes all the classes, their attributes, and methods 1.Account Class (Base Class) Attributes: accountID: Unique identifier for the account (e.g., 6221-XXXX-XXXX-XXXX). balance: Account balance (double type). transactions: List of transaction records (vector). ownerName: Name of the account owner. Methods: deposit(amount, note): Deposit money, update balance, and record the transaction. withdraw(amount, note): Withdraw money, operations executed after checking if the balance is sufficient. transfer(targetAccount, amount, note): Transfer to the target account, invoking deposit and withdraw. generateAccountReport(): Generate an account transaction report file (.txt). generateAccountID(type): Generate account ID (savings accounts start with 6221, checking accounts start with 6222). 2.SavingsAccount class (inherits from Account) Methods (overrides base class): transfer(targetAccount, amount, note): transfers are only allowed to the checking account of the same customer (check if the target account ID prefix is 6222). withdraw(amount, note): direct withdrawals are prohibited; funds must be transferred to the checking account. 3.CheckingAccount class (inherited from Account) methods: (override base class): transfer(targetAccount, amount, note): freely transfer to any account without restrictions. 4.Customer Class: Attributes: name: Customer name. savingsAccount: Customer's savings account (shared_ptr). checkingAccount: Customer's checking account (shared_ptr). Methods: generateCustomerReport(): Generates a transaction report file for all of the customer's accounts. getAllTransactions(): Merges the transaction records of savings and checking accounts. 5.Bank Class Attributes: customers: List of customers (map>). accounts: Mapping of all accounts (map>). Methods: registerNewCustomer(): Register a new customer, automatically creating savings and checking accounts. accessCustomerAccount(): Access the account menu through the customer's name. displayAllAccounts(): Display all account IDs and balances. generateTransactionReport(): Generate a global transaction report file (sorted by time). 6.Transaction Class Attributes: sourceAccountID: The ID of the account from which the transaction originates. targetAccountID: The ID of the target account for the transaction.amount: The amount of the transaction.type: The type of transaction (e.g., 'deposit', 'withdrawal', 'transfer').note: The notes for the transaction.timestamp: The timestamp of the transaction (format: YYYY-MM-DD HH:MM:SS). Methods: Provide getter methods for each attribute to generate reports. 7.IAccount Class (Interface) Purpose: Defines the generic interface for accounts. ### 二.Explanation of the Architecture 1.Layered Design: Interface Layer: IAccount defines an abstract interface for account operations, ensuring that all account types implement unified methods. Business Logic Layer: Account serves as the base class, implementing common logic (such as deposits, withdrawals, generating IDs). SavingsAccount and CheckingAccount inherit from Account, implementing specific limitations (such as transfer target restrictions, prohibition of direct withdrawals). Management Layer: Bank manages all customers and accounts, handling user interactions. Customer manages accounts associated with customers. Data Layer: Transaction records transaction data, supporting time-based sorting and report generation. 2.Core Process (1)Customer Registration: When creating a Customer object, a savings account (SavingsAccount) and a checking account (CheckingAccount) are automatically generated.Account IDs are generated by generateAccountID and registered in the Bank's accounts mapping table. (2)Account Operations: Deposits, withdrawals, and transfer operations trigger Transaction records and update account balances.Transfers from savings accounts are only allowed to checking accounts of the same customer. (3)Report Generation: Supports generating transaction reports (.txt files) by account, customer, or globally, sorted by time. 3.Design PatternsFactory Pattern: The Account's generateAccountID generates different account IDs based on type. Polymorphism: SavingsAccount and CheckingAccount override base class methods to implement differentiated logic.!