Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q : Subclass the BankAccount class from the previous question to create a MinBalanceBankAccount class. This class should require a minimum balance at all times

image text in transcribed

Q: Subclass the BankAccount class from the previous question to create a MinBalanceBankAccount class. This class should require a minimum balance at all times and should raise an exception (of the type ValueError) when an attempt to drop the balance below the minimum occurs. The MinBalanceBankAccount should be instantiated with the account number, initial balance, and the minimum balance. No error checking against the minimum balance is necessary upon instantiation.

a = MinBalanceBankAccount(account_id=1, balance=100, minimum_balance=10) a.withdraw(100) ... ValueError: Sorry, minimum balance must be maintained.

If raised, the ValueError should have the message: 'Sorry, minimum balance must be maintained.'

A minimum of extra code should be implemented in __init__ and withdraw to meet the requirements of this question.

[2 points]

The previews code:

class BankAccount: def __init__(self, number, balance=0): self.account_number = number self.balance = balance def deposit(self, amount): self.balance += amount def withdraw(self, amount): self.balance -= amount def __str__(self): return "Account ID: {} - Balance: {}".format(self.account_number, self.balance)
Q: Subclass the BankAccount class from the previous question to create a MinBalanceBankAccount class. This class should require a minimum balance at all times and should raise an exception of the type ValueError ) when an attempt to drop the balance below the minumum occurs. The MinBalanceBankAccount should be instantiated with the account number, inital balance, and the minimum balance. No error checking against the minimum balance is necessary upon instantiation. a = MinBalanceBankAccount (account_id=1, balance=100, minimum_balance=10) a. withdraw(100) ValueError: Sorry, minimum balance must be maintained. If raised, the ValueError should have the message: 'Sorry, minimum balance must be maintained.' A minimum of extra code should be implemented in _init_ and withdraw to meet the requirements of this question. [2 points)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

More Books

Students also viewed these Databases questions

Question

6-6. What are some disadvantages of business messaging? [LO5]

Answered: 1 week ago