#include #include using namespace std; // define the new type enum ResultT {YELLOW_SIGN, TENTACLE, ELDER_SIGN, CTHULHU, EYE, UNKNOWN}; //enum StatusT {ALIVE, INSANE, DEAD, UNKNOWN}; // define some useful constants to use with this type const ResultT FIRST_RESULT = YELLOW_SIGN; const size_t RESULT_COUNT = UNKNOWN - FIRST_RESULT; // define some useful functions ResultT Next(ResultT r); string ResultTToString(ResultT r); ResultT StringToResultT(string s); /* * * ResultT roll; * * roll = RollTheDie(); * cout << "you just rolled a " << ResultTToString(die) << endl; * * if (roll == YELLOW_SIGN) { * targetSanity --; * cthulhySanaty += 1; * } * */ int main() { ResultT i{YELLOW_SIGN}; for(i = FIRST_RESULT; i < UNKNOWN ; i = Next(i)) { cout << ResultTToString(i) << endl; } return 0; } ResultT StringToResultT(string s){ ResultT result; if (s == "Yellow Sign") { result = YELLOW_SIGN; } else if (s == "Tentacle") { result = TENTACLE; } else { result = UNKNOWN; } return result; } string ResultTToString(ResultT r){ string result; switch(r){ case YELLOW_SIGN: result = "Yellow Sign"; break; case TENTACLE: result = "Tentacle"; break; case ELDER_SIGN: result = "Elder Sign"; break; case CTHULHU: result = "Cthulhu"; break; case EYE: result = "Eye"; break; case UNKNOWN: default: result ="UNKNOWN"; } return result; } ResultT Next(ResultT r){ ResultT result{UNKNOWN}; if (r < UNKNOWN) { result = static_cast(r +1 ); } return result; }