The problem reported was in the specification.
How to find out ?
Write a test.
Change the 2nd parameter to a value less than the price.
i.e price = 19.5 - cash = 2.0
Run the test.
? Does the solution stop the fraud ?
Mitigation: Add to the spec definition text explaining that the cash and price is always valid so the student can ignore this and similar conditions
OR add a test and error message if cash is less than price
EXTRA CREDIT allow handling of free products
I feel like there is some language barrier here or something like that. This isn’t a relevant question at all.
We have a series of test cases we want the user to meet. We decided to keep this set of test cases simple. New learners certainly find this project plenty difficult on its own without additional complexity.
You may decide to make this project more difficult for yourself. That is fine. But those test cases that you decided that you wanted to add are outside of the design scope for this project.
I don’t see a good reason to add more requirements to this project. Just because we can make the project more complex does not mean we must. This code will never actually run a real cash register, so it is fine that it is a simplified version of the problem.