Python ATM Class (OOP)

This project is a Python class that simulates the functionality of an ATM using Object-Oriented Programming (OOP). It serves as a practical blueprint for creating individual bank account “objects” that can interact with each other. Key features include methods for deposit, withdraw, check_balance, and transfer between different account instances.

Click the badge below to run my project in Google Colab:

Open In Colab
## object oriented programing
# Create a new class 
class ATM: 
    # init = initialization (Create)
    def __init__(self, name, balance, bank):
        self.name = name
        self.balance = balance
        self.bank = bank
    
    # method => Function which is only create for this class
    def deposit(self, amt):
        self.balance += amt
        print(f"Your balance is {self.balance}")
    
    def withdraw(self, amt):
        if self.balance >= amt:
            self.balance -= amt
            print(f"Your balance is {self.balance}")
        else:
            print("Insufficient Funds")

    def check_balance(self):
        print(f"Your balance is {self.balance}")

    def transfer(self, amt, other):
        if self.balance >= amt:
            self.balance -= amt
            other.balance += amt
            print(f"Your balance is {self.balance}")
        else:
            print("Insufficient Funds")

Comments

Leave a Reply

Discover more from Firn Suchaya

Subscribe now to keep reading and get access to the full archive.

Continue reading