Python Forum
ATM machine (deposits/withdrawals) using OOP
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ATM machine (deposits/withdrawals) using OOP
#2
(Mar-09-2022, 01:08 PM)Drone4four Wrote: How would you better formulate the try/except mechanism to catch transactions which don’t allow the user to go below $0.00?

To answer my own question, this seems to be an improvement and puts me closer to getting my ATM machine to behave as intended:

    def withdraw(self, balance, amount):
        if (balance - amount) <= 0:
            raise ValueError('Transaction declined. Insufficient funds. Deposit some money first.')
            withdraw(self, balance, amount)
        else:
            return balance - amount
Reply


Messages In This Thread
RE: ATM machine (deposits/withdrawals) using OOP - by Drone4four - Mar-09-2022, 02:15 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020