This project is a simple banking management system that allows users to manage their accounts efficiently. The system includes features such as creating accounts, performing transactions, managing user data, and providing a secure interface for bank managers.
The Database Class is responsible for managing user data, including saving, loading, and authentication. It interacts with files (users.txt
and managers.txt
) to store and retrieve user information.
-
saveUsersToFile
- Saves all usernames, passwords, and account balances to
users.txt
.
- Saves all usernames, passwords, and account balances to
-
loadUsersFromFile
- Reads login information from
users.txt
and populates an unordered map of users.
- Reads login information from
-
loadManagersFromFile
- Reads manager login data from
managers.txt
and populates an unordered map of managers.
- Reads manager login data from
-
createUser
- Receives a
username
andpassword
as input, initializes the user's account balance to0
, and saves the information to the database.
- Receives a
-
deleteUser
- Removes a provided user from the database. This is used when a user requests to close their account.
-
login
- Prompts the user to enter a username and password.
- Checks if the provided credentials exist in the system.
- If the credentials are incorrect, it allows the user to try again. If correct, the user is successfully logged into their account.
The Transaction Class manages and tracks transactions made by users.
- Tracks the type of transaction performed (e.g., deposit, withdrawal).
- Records the amount of money involved in each transaction.
The Bank Account Class handles the structure and functionalities of individual bank accounts. It defines the various actions that users can perform once logged in.
-
Withdraw
- Removes a specified amount of funds from the user's account if they have sufficient balance.
-
Deposit
- Adds a specified amount of money to the user's account. This operation succeeds only if the account is currently open. Otherwise, the user is notified of the error.
-
PrintAccountSummary
- Displays the user's complete transaction history as well as their current account balance.
-
CloseAccount
- Closes the user’s account if requested and removes their login data from the database.
-
setUsername
- Updates the account with a username chosen by the user.
The Bank Manager Class is designed for bank managers to securely access user data and perform administrative tasks.
-
login
- Prompts the manager for a username and password.
- Verifies the credentials against the data in
managers.txt
. If correct, the manager is successfully logged into their account.
-
loadManagersFromFile
- Reads manager login data from
managers.txt
and stores it in an unordered map of managers.
- Reads manager login data from
-
Create a
managers.txt
file in the project directory. -
Add manager credentials in the format: Each pair of credentials must be separated by a space.
-
Place the file in the same directory as the program to allow manager logins.
To complete the banking simulation, we will display a menu of banking and account options. The user will choose from the available options by entering the corresponding number.
When logged in, the user will see a list of choices such as:
- Withdraw funds
- Deposit funds
- Print account summary
- Close account
- Log out
Managers will have a separate set of options to view and manage user data.
Testing is essential to ensure the banking system works as expected. Follow these steps to test the implementation: