/* * UserInterface.cpp * * Created on: Jul 3, 2010 * Author: gina */ #include "UserInterface.h" #include "Framer.h" #include "NaturalLanguageMenuItem.h" #include #include #include using namespace std; void UserInterface::run(){ runInteractively(); } void UserInterface::printMainMenu(){ stringstream menu; for(int i=0; itoString()<<"\n"; } Framer framedMenu(menu.str(),"Main Menu"," "); cout<> x; while ( ! cin ) { cin.clear(); string badinput; getline(cin, badinput); cerr << "Expected an integer but found " << badinput << endl << prompt; cin >> x; } // Optionally clear the remaining characters in the input stream; // for example, for a user input '123xyz', 123 is extracted to x and, // here we choose to discard 'xyz' which is still in the input stream string leftover; getline(cin, leftover); return x; // ignore leftover }