Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please extend the Account class located in bank.pyfilling in the TODOs by adding deposit and charge methods including a validation that will prevent any misuse

Please extend the Account class located in bank.pyfilling in the TODOs by adding deposit and charge methods including a validation that will prevent any misuse of those functions (unsafe operations that can influence the balance of the account  class Customer: last_id = 0 def __init__(self, firstname, lastname): self.firstname = firstname self.lastname = lastname Customer.last_id += 1 self.id = Customer.last_id def __repr__(self): return f'Customer[{self.id}, {self.firstname}, {self.lastname}]' class Account: last_id = 1000 def __init__(self, customer): self.customer = customer Account.last_id += 1 self.id = Account.last_id self._balance = 0 def deposit(self, amount): #TODO implement pass def charge(self, amount): #TODO implement pass def __repr__(self): return f'Account[{self.id}, {self.customer.lastname}, {self._balance}]' class Bank: def __init__(self): self.customer_list = [] self.account_list = [] def create_customer(self, firstname, lastname): c = Customer(firstname, lastname) self.customer_list.append(c) return c def create_account(self, customer): a = Account(customer) self.account_list.append(a) return a def __repr__(self): return f'Bank[{self.customer_list}; {self.account_list}]' bank = Bank() c = bank.create_customer('John', 'Brown') print(c) a = bank.create_account(c) a2 = bank.create_account(c) print(a) c2 = bank.create_customer('Anne', 'Smith') a3 = bank.create_account(c2) print(bank)

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

Transactions On Large Scale Data And Knowledge Centered Systems Iv Special Issue On Database Systems For Biomedical Applications Lncs 6990

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Christian Bohm ,Johann Eder ,Claudia Plant

2011th Edition

3642237398, 978-3642237393

More Books

Students also viewed these Databases questions