Skip to content
Advertisement

python – Object Oriented code for charging

Using python I want to write a code to show deposit and charging of an account. I wrote the following code, but for the charge section I don’t know what/how I should write it, I appreciate it if you could tell me how it should be:

JavaScript

Advertisement

Answer

Without a birds eye view of the whole thing, it would be hard to give a definitive answer, but I would imagine charging the customer would be done by checking if the customer’s balance is more than the charged amount, if its not maybe return some sort of message like: “Customer can’t pay the required amount” or make them go into debt. So:

JavaScript

or just:

JavaScript

Also as a side note: I don’t recommend asking these sorts of very specific questions, stack overflow is in its own way toxic towards its earlier userbase that asks very specific questions. Try to be more general and use the agreed upon structure of how a question should be asked, using foo bar baz etc.

Advertisement