Timeline for How do interactions between objects work?
Current License: CC BY-SA 4.0
8 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jun 3, 2021 at 14:06 | comment | added | Barmar | This answer may be right if you're just modeling transactions. But what if you're actually trying to show the graphics of someone inserting coins into the machine? | |
Jun 3, 2021 at 13:39 | comment | added | Swedgin |
unless your target audience is ultra rich people purchasing something extravagant from the machine (hey, it could happen) Hint: Venezuela. Don't need to be ultra rich.
|
|
Jun 3, 2021 at 7:18 | comment | added | BlueRaja - Danny Pflughoeft |
Maybe a core part of the program is that the vending machine gives a discount when certain coins are used? In that case a Coin class would make perfect sense. This answer makes a lot of assumptions that aren't necessarily valid, so doesn't really answer OP's question.
|
|
Jun 2, 2021 at 20:42 | comment | added | Greg Burghardt | @DocBrown: completely agreed. I made many assumptions in my answer. | |
Jun 2, 2021 at 19:48 | comment | added | Doc Brown | We don't see any "rules for paying and dispensing products" in the code of this question - and you might say "yes, the OP left them out for the sake of this example" - but the same may be true for a coin - maybe there are more methods in the coin class the OP left out for the same reason, so replacing it by an integral type is not an options. I stress this to make it more apparent how many assumptions are made in this answer. Of course, as I wrote, these assumptions may be perfectly right. | |
Jun 2, 2021 at 16:03 | comment | added | Greg Burghardt | @DocBrown: why would a vending machine object not be needed? Something needs to enforce the rules for paying and dispensing products. I guess the main point of my answer is to not focus on the "things" in the outside world, but the business process you are modeling. | |
Jun 2, 2021 at 13:52 | comment | added | Doc Brown |
This answer may be perfectly right. However, to be fair, the question does contain hardly enough details to know if a Coin class makes sense or not within the context of the program the OP is going to write. Following your line of argumentation, it may be enough to have a standalone integer value "number_of_inserted_coins", and not even a vending_machine object.
|
|
Jun 2, 2021 at 13:16 | history | answered | Greg Burghardt | CC BY-SA 4.0 |