Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1. This question tests your understanding of Object Oriented Programming. The follow- ing code defines the start of a class to represent bank accounts:
1. This question tests your understanding of Object Oriented Programming. The follow- ing 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. (5 marks) (b) Add instance methods called deposit () and withdraw () which increase and decrease the balance of the account. Make sure the withdraw() method doesn't 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 multi- plied by the current balance). (14 marks) (c) Create a subclass of BankAccount called Student Account. Every Student Account 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. (14 marks)
Step by Step Solution
★★★★★
3.48 Rating (161 Votes )
There are 3 Steps involved in it
Step: 1
In the given code snippet there are class variables and instance variables defined within the BankAccount class Lets identify them Class Variables int...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