Answered step by step
Verified Expert Solution
Link Copied!

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... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial accounting

Authors: Walter T. Harrison, Charles T. Horngren, William Bill Thomas

8th Edition

9780135114933, 136108865, 978-0136108863

More Books

Students also viewed these Programming questions