diff --git a/Oops concepts in python. Class . b/Oops concepts in python. Class . new file mode 100644 index 0000000..6d5077c --- /dev/null +++ b/Oops concepts in python. Class . @@ -0,0 +1,47 @@ +# Base class: BankAccount +class BankAccount: + def __init__(self, account_number, owner, balance=0): + self.account_number = account_number + self.owner = owner + self.balance = balance + + def deposit(self, amount): + if amount > 0: + self.balance += amount + print(f"Deposited {amount}. New balance: {self.balance}") + else: + print("Deposit amount must be positive.") + + def withdraw(self, amount): + if amount > 0 and amount <= self.balance: + self.balance -= amount + print(f"Withdrew {amount}. New balance: {self.balance}") + else: + print("Insufficient balance or invalid withdrawal amount.") + + def display_balance(self): + print(f"Account Number: {self.account_number} | Owner: {self.owner} | Balance: {self.balance}") + +# Derived class: SavingsAccount +class SavingsAccount(BankAccount): + def __init__(self, account_number, owner, balance=0, interest_rate=0.01): + super().__init__(account_number, owner, balance) + self.interest_rate = interest_rate + + def apply_interest(self): + interest = self.balance * self.interest_rate + self.balance += interest + print(f"Interest of {interest} applied. New balance: {self.balance}") + +# Derived class: CheckingAccount +class CheckingAccount(BankAccount): + def __init__(self, account_number, owner, balance=0, overdraft_limit=500): + super().__init__(account_number, owner, balance) + self.overdraft_limit = overdraft_limit + + def withdraw(self, amount): + if amount > 0 and (self.balance + self.overdraft_limit) >= amount: + self.balance -= amount + print(f"Withdrew {amount}. New balance: {self.balance}") + else: + print("Withdrawal exceeds overdraft limit diff --git a/README.md b/README.md deleted file mode 100644 index 6e53c4c..0000000 --- a/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# FlutterClass - -More details : https://github.com/ViluppuramGLUG/FlutterClass/tree/main/vglug