Question: IN PYTHON, Implement a class Account which represents a simple current account. The class should have the following functionality... When the account is created it

IN PYTHON, Implement a class Account which represents a simple current account. The class should have the following functionality...

When the account is created it should be possible to specify an initial balance and an overdraft limit. If these are not given, they should be assumed to be zero. Assume that there is no interest to be paid when the overdraft facility is used.

Your class Account should provide a method pay in which takes an argument deposit and records that deposit.

Your class Account should provide a method pay out which takes an argument amount and records that withdrawal. Note that if required the amount paid out should be reduced so that the overdraft is not exceeded. The function should return the amount paid out.

Your class Account should provide a method get balance which shows the current balance.

Your class Account should provide a method get transactions which should list the transactions.

Construct your class Account so that no redundant information is stored. The code example below should illustrate the use of the class.

acc = Account(overdraft=500)

acc.pay in(500)

acc.pay out(900) # should return 900

acc.pay out(200) # should return 100, as overdraft limit reached

print(acc.get balance()) # should print -500

print(acc.get transactions()) # shoud print deposit of 500, withdrawal of # 900 and 100

(b) Now implement a class Bank that provides the following three methods.

Your class Bank should have a method create account which returns a new Account and registers it with the Bank. It should be possible to (optionally) specify the initial balance and the overdraft limit.

Your class Bank should have a method remove account which takes an Account as argument and re- moves it from the list of accounts.

Your class Bank should have a method get balance which returns the sum of the balances of the accounts held with the bank.

The code example below should illustrate the use of the class.

bank = Bank()

acc1 = bank.create account()

acc2 = bank.create account(overdraft=200)

acc1.pay in(50)

acc2.pay out(100)

print(bank.get balance()) # should print -50

bank.remove account(acc1)

print(bank.get balance()) # should print -100

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!