Skip to content

Bharat-css/AtmProject

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

ATM Workflow in Python

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.

Features

  • 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.

How to Run

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).

File Structure

.
├── ATM.py
└── Atm Management Project/
    ├── balance.txt
    └── password.txt
  • ATM.py: The main Python script containing the Atm class and the main 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).

Code Overview

The ATM.py file contains:

  • Atm Class:
    • __init__: Initializes file paths for balance.txt and password.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 the main 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.

Important Notes

  • 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.

Contributing

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!

About

A basic ATM Machine working project

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages