Concept How It Appears
Class User, BankUser, Admin
Object user1 = BankUser(...)
Encapsulation __atm_pin (private) and accessed via methods
Abstraction Hides PIN logic and transaction logic via methods
Inheritance BankUser and Admin inherit from User
Polymorphism show_user_type() behaves differently based on object type

šŸŽÆ OOP CONCEPTS DEMO IN PYTHON

āœ… BASE CLASS (Encapsulation + Abstraction)

class User: def init(self, name, atm_pin): self.name = name self.__atm_pin = atm_pin # Encapsulated (private) attribute

def authenticate(self):
    """šŸ”’ Method to check PIN (Abstraction)"""
    pin = input("Enter your ATM PIN: ")
    if pin == self.__atm_pin:
        print("āœ… Access Granted!")
        return True
    else:
        print("āŒ Access Denied!")
        return False

def change_pin(self):
    """šŸ”‘ Change PIN securely"""
    if self.authenticate():
        new_pin = input("Enter your NEW ATM PIN: ")
        self.__atm_pin = new_pin
        print("šŸ” PIN changed successfully!")

def show_user_type(self):
    """šŸ”Ž Demonstrates Polymorphism (to be overridden)"""
    print("šŸ‘¤ I am a general user.")

āœ… CHILD CLASS (Inheritance)

class BankUser(User): def init(self, name, atm_pin, balance=0.0): super().init(name, atm_pin) self.balance = balance # New property in child class

def withdraw(self):
    """šŸ’ø Withdraw money"""
    if self.authenticate():
        try:
            amount = float(input("Enter amount to withdraw: "))
            if amount > self.balance:
                print("ā— Insufficient balance.")
            else:
                self.balance -= amount
                print(f"āœ… Withdrawn ₹{amount}. New Balance: ₹{self.balance}")
        except ValueError:
            print("āŒ Invalid amount entered.")

def deposit(self):
    """šŸ’° Deposit money"""
    try:
        amount = float(input("Enter amount to deposit: "))
        self.balance += amount
        print(f"āœ… Deposited ₹{amount}. New Balance: ₹{self.balance}")
    except ValueError:
        print("āŒ Invalid amount entered.")

def show_user_type(self):
    """šŸ‘¤ Overridden method (Polymorphism)"""
    print("šŸ¦ I am a Bank User.")

āœ… ANOTHER CHILD CLASS (Polymorphism + Inheritance)

class Admin(User): def show_user_type(self): """šŸ‘¤ Overridden method""" print("šŸ› ļø I am an Admin.")

āœ… OBJECT CREATION (Demonstrating Objects)

if name == "main":

Create a BankUser

user1 = BankUser("Alice", "1234", balance=5000)

# Create an Admin
admin1 = Admin("AdminUser", "0000")

# Simple Menu
print("\\nWelcome to Python Bank šŸ¦")
print("-------------------------")

# Choose a user
print("\\nšŸ”¹ Choose a user:")
print("1. Bank User (Alice)")
print("2. Admin User")
choice = input("Enter your choice (1 or 2): ")

if choice == "1":
    print("\\n--- Bank User Menu ---")
    user1.show_user_type()
    print("1. Deposit")
    print("2. Withdraw")
    print("3. Change PIN")
    action = input("Choose action: ")

    if action == "1":
        user1.deposit()
    elif action == "2":
        user1.withdraw()
    elif action == "3":
        user1.change_pin()
    else:
        print("āŒ Invalid Option.")

elif choice == "2":
    print("\\n--- Admin Menu ---")
    admin1.show_user_type()
    admin1.change_pin()

else:
    print("āŒ Invalid User Choice.")