/* Lecture Code 1.0
 *
 * The GetLine, GetInteger, and IntegerToString functions.
 */

#include <iostream>
#include <string>
#include <sstream>
using namespace std;

string GetLine()
{
	string result;
	getline(cin, result);
	return result;
}

string IntegerToString(int value)
{
	stringstream converter;
	converter << value;
	return converter.str();
}

int GetInteger()
{
	while(true)
	{
		stringstream converter;
		converter << GetLine();
		
		int result;
		converter >> result;
		if(converter.fail())
			cout << "Please enter an integer." << endl;
		else
		{
			char ch;
			converter >> ch;
			
			if(converter.fail())
				return result;
			else
				cout << "Unexpected character: " << ch << endl;
		}
		
		cout << "Retry: ";
	}
}