#include #include using namespace std; enum class SizeT:char {TINY, SMALL, MEDIUM, LARGE, HUGE, GARGANTUAN, NONE}; const size_t SIZES {static_cast(SizeT::NONE)}; string SizeTToString(SizeT size); int SizeDifference(SizeT first, SizeT second); SizeT RandomSize(); string FindAction(int diff); string HugeComment(SizeT size); int main() { SizeT one, two; int i; int sizeDifference; for(i = 0; i < 10; i++) { one = RandomSize(); two = RandomSize(); sizeDifference = SizeDifference(one,two); cout << "A " << SizeTToString(one) << " critter meets a " << SizeTToString(two) << " critter." << endl; cout << "\tThe difference in sizes is " << sizeDifference << "." << endl; cout << "\tSo the critters " << FindAction(sizeDifference) << "." << endl; if (one == SizeT::HUGE) { cout << "Creature one says " << HugeComment(two) << endl; } cout << endl; } return 0; } string FindAction(int diff) { string action; switch(diff) { case 0: action = "make friends"; break; case 1: action = "look at each other in amazement"; break; default: action = "fail to notice each other"; break; } return action; } int SizeDifference(SizeT first, SizeT second){ int firstSize, secondSize; firstSize = static_cast(first); secondSize = static_cast(second); return abs(firstSize-secondSize); } SizeT RandomSize() { int i = rand() % SIZES; return static_cast(i); } string SizeTToString(SizeT size){ string name{"unknown"}; switch(size) { case SizeT::TINY: name = "tiny"; break; case SizeT::SMALL: name = "small"; break; case SizeT::MEDIUM: name = "medium"; break; case SizeT::LARGE: name = "large"; break; case SizeT::HUGE: name = "huge"; break; case SizeT::GARGANTUAN: name = "gargantuan"; break; default: cout << "Error, unknown size" << endl; } return name; } string HugeComment(SizeT size){ string response; switch(size) { case SizeT::TINY: case SizeT::SMALL: case SizeT::GARGANTUAN: response = "What, I don't see you!"; break; case SizeT::MEDIUM: response = "Look at that tiny little thing!"; break; case SizeT::LARGE: response = "Will you be my friend?"; break; case SizeT::HUGE: response = "Look at that big thing!"; break; default: response = "I don't know what size that thing is!"; } return response; }