This project was hard. so hard, in fact, that I’ve decided to post my solution as a starting point for people who may be stuck. It’s not the most optimized code I’ve ever written, but it works, and that’s the important part. Good luck to everyone stuck on this hair-puller of a project.
Thank you for sharing your code online, it will help many people stuck on this project! However, I would like to point out some areas in your code that have bugs (i.e does not work), so others reading this can be aware of them when consulting your solution.
One bug I found occurs when the program asks the user to enter an amount of starting money. If the user inputs a character or sequence of characters, a message notifying the user to enter an integer gets printed an infinite number of times (infinite loop). Also, if a negative number is inputted then the program simply stops working as intended and does not let you takeout food.
Similar bugs occur whenever the program asks the user “would you like to proceed?”, “enter a menu item”, and “enter 1 to continue shopping and 2 to checkout”. If the user enters a sequence of characters, a message gets printed out infinitely, similar to what occurs in the previous bug. These bugs all stem from the loop in the main method.
Additionally, the getFood method is missing some important code. Because the method does not check to ensure that the index is within bounds (the directions specify that you write this check before returning the food object), the program throws an index out of bounds error message whenever an index out of bounds is entered by the user.
There were some other design and optimization issues present in the code but it seems that you are aware of that (for example, the TakeoutSimulator constructor having a FoodMenu as a parameter when it does not have to, and the implementations of IntUserInputRetriever using wildcards instead of defined types like Boolean and Food). However, I completely agree with you in that this project was pretty hard to grasp at first for me when I started it. There are many sections that are difficult to grasp and the way the steps are written does not help.
I suggest that you test out your code with different inputs to ensure that it works as intended. If you would like to refer to an in depth walkthrough of the project, refer to this video: Let's Get Takeout! Codeacademy Full Project Walkthrough - YouTube