Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

USE PYTHON!!!!! Develop a class BankAccount with six methods: a. init - constructor, is able to construct a bank account with a given balance, or,

USE PYTHON!!!!!

Develop a class BankAccount with six methods:

a. init - constructor, is able to construct a bank account with a given balance, or, if no balance is specified the balance defaults to 0. (see runs below)

b. repr - converts BankAccount to a str for display, see runs below.

c. set which takes a numeric amount as a parameter and sets the account balance to that parameter

d. withdraw - which takes a numeric amount as a parameter and withdraws the amount specified by the parameter from the balance on the account

e. deposit - which takes a numeric amount as a parameter and deposits the amount specified by the parameter from the balance on the account

f. balance - which takes no parameters and returns the current balance on the account

# constructor/repr

>>> b = BankAccount(100)

>>> b

BankAccount(100)

>>> b = BankAccount()

>>> b

BankAccount(0)

>>> [b] # check that str is returned, not printed

[BankAccount(0)]

# methods

>>> b.deposit(50.25)

>>> b

BankAccount(50.25)

>>> b.withdraw(17.50)

>>> b

BankAccount(32.75)

>>> b.balance()

32.75

>>> b.balance()==32.75 # check balance is returned, not printed

True

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

Oracle 10g Database Administrator Implementation And Administration

Authors: Gavin Powell, Carol McCullough Dieter

2nd Edition

1418836656, 9781418836658

More Books

Students also viewed these Databases questions

Question

How can the S&L crisis be blamed on the principal-agent problem?

Answered: 1 week ago

Question

4-57. The employees were represented by Janet Hogan.

Answered: 1 week ago