Is there a reason why State is an interface and not an abstract class? In general, when do you choose interface over abstract class and vice versa?
Also I believe all the state functions should return a new state, instead of void. For example, calling VendingMachine’s function insertMoney() will invoke currentState’s insertMoney() and that should return a new state and we can set currentState to that new state. Let me know if you think this is incorrect? Thanks!
Course: Grokking the Low Level Design Interview Using OOD Principles - Learn Interactively
Lesson: Class Diagram for the Vending Machine - Grokking the Low Level Design Interview Using OOD Principles