You should call buy() in the Pharmacy class and sell() in the Person class. It's quite obvious, if you read only the methods' names. However, if you read this two (or see the output), the other pairing is more logical.
Do not dig too deep...
You must be signed in to leave a comment
21 September 2020, 10:47
Yeah, what's with the logic of this one? The people are selling drugs to the DrugController, and in turn the pharmacy is buying drugs from the DrugController. And yet the sell method prints outwhile it should be saying "sold" instead of "purchased".
21 September 2020, 15:15
I think you are reading the task incorrectly. The drugController class is to be thought of as the inventory of the Pharmacy. The Pharmacy class uses the buy method because it is buying more inventory and the Person class uses the sell method because the inventory is being sold to the Person. You should be looking at this as you are programming the logic from the inventory's perspective, not the customer's.
22 September 2020, 08:07
If it is as you say so, why then, when the sell method is run, the amount of the drug in the inventory increases:This is the very last line of the sell method. If it were as you say so, then the count in the inventory would obviously be going down, and not up. And on the flip side of the coin, the buy method should be increasing the amount in the inventory according to your explanation if the pharmacy is stocking up, but the opposite is happening: As the title says, it's best not to dig too deep, as there is no sense to be made of this.
22 September 2020, 13:16
it looks like they changed the starting code for this task. When I completed this task back in 2018, my buy and sell methods were:The same code as this question from 2018: https://codegym.cc/help/1317 Now the code is the opposite. Someone at codegym either thought the old logic was backwards, or they wanted to make this task more of a challenge and have the programmer pay attention.
22 September 2020, 21:38
That could very well be the case. To me, the version you worked with makes more sense. Have a good one.
26 July 2020, 01:28
I agree. I was confused who is buying and who is selling and why drug count increases when it's sold.