-
-
Notifications
You must be signed in to change notification settings - Fork 18
Closed
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is neededquestionFurther information is requestedFurther information is requested
Description
Problem: Implement a Simple Bank Account System Using OOPs in Python
Objective:
Use Object-Oriented Programming concepts in Python to build a basic bank account system.
✅ Concepts to Implement:
- Encapsulation
- Inheritance
- Polymorphism
- Abstraction (optional)
🛠️ Requirements:
-
Create a base class
BankAccountwith the following:-
Attributes:
account_holder,balance -
Methods:
deposit(amount)withdraw(amount)display_balance()
-
-
Encapsulation:
- Make
balancea private variable using double underscore (__balance) - Use getter method if needed
- Make
-
Inheritance:
- Create a subclass
SavingsAccountthat inherits fromBankAccount - Add an attribute:
interest_rate - Method:
apply_interest()which updates balance
- Create a subclass
-
Polymorphism:
- Override
display_balance()in the subclass to also show interest rate
- Override
-
Abstraction (Optional):
- Use the
abcmodule to create an abstract base class if needed
- Use the
Example Usage:
acc = SavingsAccount("John Doe", 1000, 0.05)
acc.deposit(500)
acc.withdraw(200)
acc.apply_interest()
acc.display_balance()Expected Output:
Deposited 500
Withdrawn 200
Interest applied
Account Holder: John Doe
Balance: 1365.0
Interest Rate: 5.0%
📌 Acceptance Criteria:
- Code must be in Python.
- Step : Go to Learn-python-language Create a Folder : then Start a Project
- Follow clean naming and formatting.
Checklist:
- Create
BankAccountclass - Implement encapsulation with private balance
- Inherit
SavingsAccountfromBankAccount - Override a method (polymorphism)
- (Optional) Use abstract class
- Add example usage and test the output
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is neededquestionFurther information is requestedFurther information is requested