Hello kreezy,
The first thing I noticed is that the main menu has no way to exit the program.If the idea is that the program runs all the time this is fine, but you may want to add an exit choice for testing while writing the program.This does not have to show up in the menu choices.
Next I found that the menu prints out 10 choices, but there are 11 available because when I entered 11 to see what would happen it told me that I chose a Barbie Doll that was not listed on the menu.
In the file "vendingMachine.cpp" in the function "PrintAllItems()" the for loop starts at 1 when it should start at zero.Keep in mind that C++ is zero based meaning containers like "string"s, "vector"s, "list"s and "array"s all start their indxing at zero.If you want the for loop to start at 1 then you will have to make the container one larger than you need or set up the prgram to always skip element zero.
The prompt for entering the money was a problem the first time because I did not understand it correctly.After a couple of attempts I got it write.You might want to consider revising the prompt.Just a suggestion.
When the menue prints for me the item numbers are out of order.It starts with "Beverages" at 4 followed by "Chips" with 1 and finishes with "toys" at 9. Not sure where the problemis yet, but it looks better when the numbers are in proper order.Just a small thing.
In the program I found "Sleep(5000);". This is only available to Windows computers and not available to everyone. I have found this to be a good replacement for "Sleep"
std::this_thread::sleep_for(std::chrono::seconds(5)); // Requires header files "chrono" and "thread"
. The only thing you have to worry about is the number 5. This is the number of whole seconds the code will pause for.
After that the use of "System" anything should be avoided. "CLS" is not available to everyone. For "pause" I generally use this code:
1 2 3 4
|
// The next line may not be needid. If you have to press enter to see the prompt it is not needed.
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); // <--- Requires header file <limits>.
std::cout << "\n\n Press Enter to continue";
std::cin.get();
|
To clear the screen I use a function, but it uses the "Windows.h" header file , so it is only for personal use.
From what I can tell the rest of the program appears to work OK.
Hope that helps,
Andy