#include "VendingMachine.h" #include #include using namespace std; void PrintMenu() { cout << "Please make a selection" << endl << endl; cout << "1. Show available sodas" << endl; cout << "2. Vend" << endl; cout << "3. Stock" << endl; cout << "4. Withdraw" << endl; cout << "5. Quit" << endl << endl; cout << "Your choice: "; } void ShowSodas(VendingMachine* vm) { cout << endl << "Avaiable sodas" << endl; cout << "--------------" << endl; vm->DisplayTypes(); cout << endl; } void Vend(VendingMachine* vm) { int type; ShowSodas(vm); cout << "What type of soda would you like? "; cin >> type; cout << endl; if ((type >=0) && (type < NUM_TYPES)) vm->Vend(type); cout << endl; } void Stock(VendingMachine* vm) { int type; cout << endl << "What type of soda do you want to stock (0 - " << NUM_TYPES-1 << ")? "; cin >> type; cout << endl; if ((type >=0) && (type < NUM_TYPES)) vm->Stock(type); cout << endl; } void Withdraw(VendingMachine* vm) { cout << endl; vm->WithdrawCash(); cout << endl; } int main(int argc, char* argv[]) { VendingMachine myMachine; int Choice = 0; while (Choice != 5) { PrintMenu(); cin >> Choice; switch (Choice) { case 1 : ShowSodas(&myMachine); break; case 2 : Vend(&myMachine); break; case 3 : Stock(&myMachine); break; case 4 : Withdraw(&myMachine); break; case 5 : break; default : cout << endl << "That was an invalid choice! Try again, bozo." << endl; } } return 0; }