Add a property to the BankAccount
class named transaction_fee
for a real number representing an amount of money to deduct every time the user withdraws money.
Use your BankAccount
class solution from the previous exercises as a starting point to solve this exercise.
Suppose that a class of objects named BankAccount
has already been created that remembers information about a user's account at a bank.
The class includes the following public members:
member name |
type |
description |
BankAccount(name) |
constructor |
constructs a new account for the person with the given name, with $0.00 balance |
ba._name ,
ba._balance
|
data attributes |
private attributes storing account's name and balance |
ba.name |
property |
the account name as a string (read-only) |
ba.balance |
property |
the account balance as a real number (read-only) |
ba.deposit(amount) |
method |
adds the given amount of money, as a real number, to the account balance; if the amount is negative, does nothing |
ba.withdraw(amount) |
method |
subtracts the given amount of money, as a real number, from the account balance; if the amount is negative or exceeds the account's balance, does nothing |
Add a property to the class named transaction_fee
for a real number representing an amount of money to deduct every time the user withdraws.
The default value is $0.00, but the client can change the value.
Deduct the transaction fee money during every withdraw
call (but not from deposits).
Make sure that the balance cannot go negative during a withdrawal.
If the withdrawal (amount plus transaction fee) would cause it to become negative, don't modify the balance at all.
Do not allow negative transaction fees; if the client attempts to set a negative transaction fee, leave its value unchanged.
Since adding this property changes several parts of the class, write and submit an entirely new version of the complete BankAccount
class, along with its constructors, properties, methods, etc.
You may want to copy/paste your solution from the BankAccount
exercise as a starting point.