Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using the attached Python class, write a unit test program to test it's complete functionality, which means you test every method for correctness. There are

Using the attached Python class, write a unit test program to test it's complete functionality, which means you test every method for correctness. There are errors, your job is not to fix them, but to find them with unit testing. Don't forget, documentation and commenting are a MUST! If the code does not run properly I will downvote. Here is the class program:

class BankAccount :
## Constructs a bank account with a given balance.
# @param initialBalance the initial account balance (default = 0.0)
#
def __init__(self, initialBalance = 0.0) :
self._balance = initialBalance

## Deposits money into this account.
# @param amount the amount to deposit
#
def deposit(self, amount) :
self._balance = self._balance + amount

## Makes a withdrawal from this account, or charges a penalty if
# sufficient funds are not available.
# @param amount the amount of the withdrawal
#
def withdraw(self, amount) :
PENALTY = 10.0
if amount > self._balance :
self._balance = self._balance - PENALTY
else :
self._balance = self._balance - amount

## Adds interest to this account.
# @param rate the interest rate in percent
#
def addInterest(self, rate) :
amount = self._balance * rate / 100.0
self._balance = self._balance + amount

## Gets the current balance of this account.
# @return the current balance
#
def getBalance(self) :
return self._balance

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_2

Step: 3

blur-text-image_3

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

13th edition

1439078106, 111197375X, 9781439078105, 9781111973759, 978-1439078099

More Books

Students also viewed these Finance questions

Question

Psychological issues associated with officiating/refereeing

Answered: 1 week ago

Question

What kinds of firms use commercial paper?

Answered: 1 week ago