Question
Hi, Please see question below. It is an OOP question in the Python language. I would be grateful for any help with this question. This
Hi, Please see question below. It is an OOP question in the Python language. I would be grateful for any help with this question.
This question tests your understanding of Object Oriented Programming. The following code defines the start of a class to represent bank accounts:
class BankAccount(object):
interest_rate = 0.3
def __init__(self, name, number, balance):
self.name = name
self.number = number
self.balance = balance
return
(a) Name the class variables and the instance variables in the given code.
(b) Add instance methods called deposit() and withdraw() which increase and decrease the balance of the account. Make sure the withdraw() method doesnt allow the account to go into overdraft. Add a third method called add interest() which adds interest to the balance (the interest should be the interest rate multiplied by the current balance).
(c) Create a subclass of BankAccount called StudentAccount. Every StudentAccount should have an overdraft limit of 1000. Write a constructor for the new class. Override the withdraw() method to make sure that students can withdraw money up to their overdraft limits
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started