// Lecture5.cpp : Defines the entry point for the console application. // #include "stdafx.h" void PrintMenu() { cout << endl << "Please make a selection" << endl << endl; cout << "1. Make a car" << endl; cout << "2. Accelerate" << endl; cout << "3. Decelerate" << endl; cout << "4. Drive a car" << endl; cout << "5. Quit" << endl << endl; cout << "Your choice: "; } void MakeCar(Car* C) { char type[80]; int max_speed; cout << "Please tell me the make and model: "; cout.flush(); gets(type); cout << "What's the max speed? "; cin >> max_speed; cout << endl << "OK - here we go!" << endl << endl; C->Decelerate(C->Max_Speed); C->Set_Model_Make(type); C->Max_Speed = max_speed; cout << "You've now got a '" << C->Get_Model_Make() << "' car!" << endl; } void Accelerate(Car* C) { int how_much; cout << endl << "How much should I accelerate? "; cin >> how_much; cout << endl; C->Accelerate(how_much); } void Decelerate(Car* C) { int how_much; cout << endl << "How much should I decelerate? "; cin >> how_much; cout << endl; C->Decelerate(how_much); } void Drive(Car* C) { cout << endl; C->Drive(); // (*C).Drive(); } int main(int argc, char* argv[]) { int Choice = 0; Car Current_Car("Pinto"); while (Choice != 5) { PrintMenu(); cin >> Choice; switch (Choice) { case 1 : MakeCar(&Current_Car); break; case 2 : Accelerate(&Current_Car); break; case 3 : Decelerate(&Current_Car); break; case 4 : Drive(&Current_Car); break; case 5 : break; default : cout << endl << "That was an invalid choice! Try again, bozo." << endl; } } return 0; }