This project simulates a basic ATM (Automated Teller Machine) workflow using Python. It demonstrates fundamental concepts of object-oriented programming, file handling for data persistence (balance and password), and a simple command-line interface.
- Check Balance: View the current account balance.
- Withdraw Money: Withdraw funds from the account, with checks for insufficient balance.
- Deposit Money: Deposit funds into the account.
- Reset Password: Change the ATM PIN.
- Check Current Password: Display the currently set PIN.
- Secure (Basic) Password Check: Requires a password to access ATM operations.
1. Clone the repository (or download the ATM.py
file):
git clone <https://github.com/Bharat-css/AtmProject>
cd <repository-directory>
(Replace <repository-url>
and <repository-directory>
with your actual repository details if you have one.)
2. Create necessary files:
The script uses two files for data persistence. Please create these empty files in a directory named
Atm Management Project
in the same directory as ATM.py
:
Atm Management Project/balance.txt
Atm Management Project/password.txt
You can create these manually or use the following commands in your terminal:
mkdir "Atm Management Project"
touch "Atm Management Project/balance.txt"
touch "Atm Management Project/password.txt"
3. Run the Python script:
python ATM.py
4. Follow the on-screen prompts:
- Enter your name.
- Enter your password (initially, you might need to set one by directly editing
password.txt
or using the "Reset Your PASSWORD" option after an initial run). - Choose from the menu options (Check Balance, Withdraw, Deposit, Reset Password, Check Password, Exit).
.
├── ATM.py
└── Atm Management Project/
├── balance.txt
└── password.txt
ATM.py
: The main Python script containing theAtm
class and themain
function to run the ATM simulation.Atm Management Project/balance.txt
: Stores the current account balance.Atm Management Project/password.txt
: Stores the ATM password (PIN).
The ATM.py
file contains:
Atm
Class:__init__
: Initializes file paths forbalance.txt
andpassword.txt
.check_balance()
: Reads and displays the current balance.withdraw(amount)
: Handles money withdrawal, updates the balance file.deposit(amount)
: Handles money deposit, updates the balance file.atm_password(pin)
: Checks if the entered PIN matches the stored PIN.reset_password(new_pin)
: Updates the password file with a new PIN.check()
: Displays the current password.
greet(fx)
Decorator: A simple decorator to add welcome and thank you messages around themain
function execution.main()
Function:- The entry point of the ATM simulation.
- Prompts the user for their name and password.
- If the password is correct, it enters a loop presenting the ATM menu.
- Handles user choices and calls the appropriate
Atm
class methods. - Includes basic error handling for
ValueError
when expecting numerical input.
- Security: This project uses basic file handling for storing balance and password. It is not secure for real-world applications. Passwords are stored in plain text, and there's no encryption or robust error handling for file operations.
- Error Handling: Basic
try-except
blocks are used for file operations and input validation, but more comprehensive error handling would be needed for a production-ready system. - Data Persistence: The balance and password are saved to text files, so they persist between runs of the script.
If you'd like to fork this project, add new features, or modify existing ones, here are some suggestions for improvements:
- Enhanced Security: Implement proper hashing for passwords and consider using a more robust database (e.g., SQLite, PostgreSQL) instead of plain text files for storing sensitive information like balance and passwords.
- User Accounts: Extend the system to support multiple user accounts, each with their own balance and password.
- Transaction History: Add a feature to log and display a history of all transactions (withdrawals, deposits).
- Error Handling Improvements: Implement more specific error handling for file operations (e.g., file not found, permission errors) and user input.
- User Interface: Develop a graphical user interface (GUI) using libraries like Tkinter, PyQt, or Kivy for a more user-friendly experience.
- Input Validation: Add more comprehensive input validation to prevent non-numeric inputs for amounts or passwords where numbers are expected.
- Unit Tests: Write unit tests for the `Atm` class methods to ensure their correctness and prevent regressions.
- Concurrency/Multi-threading: (Advanced) If considering a more complex system, think about how to handle concurrent access to the balance file if multiple operations were to occur simultaneously.
- Code Refactoring: Improve code readability, modularity, and adherence to Python best practices (PEP 8).
Feel free to open issues or pull requests with your contributions!