Quad tree search badtypeexception.cc
Revision as of 20:41, 3 July 2016 by Maintenance script (talk)
#ifndef BADTYPEEXCEPTION_CC #define BADTYPEEXCEPTION_CC #include "TemasBase.h" #ifdef __USE_STD_IOSTREAM #include <exception.h> #else #include <exception> #endif #include <string> using namespace std; class BadTypeException: public exception { string Error_string; public: BadTypeException() { Error_string = "BadTypeException:"; } BadTypeException( const BadTypeException &B ) { Error_string = B.Error_string; } ~BadTypeException(){} BadTypeException(string s) { Error_string += s; } virtual const char* what() { return Error_string.data(); } void test( char type_char ) throw (BadTypeException) { switch( type_char ) { case 'L': // 'L' - lab, break; case 'B': // 'B' - barrack, break; case 'S': // 'S' - supply, break; case 'P': // 'P' - power break; case 'M': // 'M' - mineral. break; default: throw BadTypeException( "BadTypeException: The type must be F, W, P, I or C.\n" ); } } // test }; #endif // BADTYPEEXCEPTION_CC