Write in PYTHON 3 Only Thank You Define a class for a restricted saving account
ID: 3812003 • Letter: W
Question
Write in PYTHON 3 Only
Thank You
Define a class for a restricted saving account that only permits three withdraw per months (see SavingsAccount class in slides) class RestrictedSavingsAccount(SavingsAccount): """This class represents a restricted savings account.""" MAX_WITHDRAWALS = 3 def _init_(self, name, pin, balance = 0.0): """Same attributes as SavingsAccount, but with a counter for withdrawals.""" def withdraw(self, amount): """Restricts number of withdrawals to MAX WITHDRAWALS.""" def resetCounter(self): self, counter = 0Explanation / Answer
Since you have not given SavingsAccount class, I presume name, pin and balance to be present in the SavingsAccount class.
class RestrictedsavingsAccount (SavingsAccount):
"This class represents a restricted savings account."
MAX_WITHDRAWALS = 3
_Counter = 0
def __init__ (self, name, pin, balance = 0.0):
"""Same attributes as Savings Account,
but with a counter for withdrawals."""
super().__init__(name, pin, balance)
resetCounter()
def withdraw (self, amount):
"""Restricts number of withdrawals to MAX WITH DRAWALS."""
self._Counter = self._Counter + 1
if(self._Counter > 3):
print("Withdrawl Limits exceeded !!!. Cannot Withdraw anymore.")
else:
# Continue withdrawing
def resetCounter(self):
self._Counter = 0
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.