Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

class BankAccount(): def __init__(self, acc_num, balance): self.account_number = acc_num # will store the account number self.balance = balance # will store the account balance #

class BankAccount(): def __init__(self, acc_num, balance): self.account_number = acc_num # will store the account number self.balance = balance # will store the account balance # TASK 2 def deposit(self, amount): if amount > 0: self.balance += amount # add amunt to balance else: print('Error: You cannot deposit negative amount.') return self.balance def withdraw(self, amount): if amount < 0: print('Error: Withdrawl amount cannot be negative.') elif amount > self.balance: print('Error: You cannot withdraw more than your account balance.') else: self.balance -= amount # subtract amountfrom balance return self.balance # TASK 3 def __str__(self): return 'Account Number: {}, Balance: ${:,.2f}'.format(self.account_number, self.balance) # returns banks balance def __len__(self): return self.balance # checks two account number are same or not def __eq__(self, other): if self.account_number == other.account_number: return True else: return False def main(): # create 2 objects of BankAccount class acct1 = BankAccount('ACC_123', 100.00) acct2 = BankAccount('ACC_124', 500.00) acct1.deposit(100) # deposit 100, acct1.withdraw(150) # withdraw 150 print(acct1) # balance = 100+100-150 = $50 acct2.withdraw(900) # withddraw more than balance acct2.deposit(-100) # deposit negative amount print(acct2) # print the account number and balance # checks two account are same or not? print('Account1==Account2?',acct1==acct2) main() 

Task 04 (30 points)

Now its time to get some use out of your class. You will create the following:

- Define a new class that inherits from your previous class

- Override one of your methods to provide new functionality

- Define a new method specific to this class

Now were going to add some more complexity to our class. You are to add the following:Task 05 (30 points)

- Create a new class that inherits from your original class

- Add two new private class variables

- Override the constructor to only accept these new variables

- Override one of your methods to accept a numeric value and use that in a condition

- Add a class variable that is a number

- Add a new method that will take in a number and add it to with the previously created numeric value so long as it is within a certain range

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

Visual Basic Net Database Programming

Authors: Rod Stephens

1st Edition

0789726815, 978-0789726810

More Books

Students also viewed these Databases questions

Question

7. Senior management supports the career system.

Answered: 1 week ago