awesome-low-level-design
awesome-low-level-design copied to clipboard
vendingMachine.resetPayment(); should be after the if, else flow
The below line should be after the if, else flow, as it doesn't matter if the change to return is greater than 0 or not, we need to make the totalPayment to 0.0 again, for next transaction, as we are doing for selectedProduct after the if, else block.
https://github.com/ashishps1/awesome-low-level-design/blob/482e3faacab908dc8d5e8326c95cf9d410a0a53b/solutions/java/src/vendingmachine/ReturnChangeState.java#L35