#include "bob.h" #include #include #include namespace bob { using namespace std; namespace { void trim_spaces(string &str) { str.erase(remove_if(str.begin(), str.end(), [](char c){return isspace(static_cast(c));}), str.end()); } string to_uppercase(const string &str) { string result = str; for (auto & c: result) c = toupper(c); return result; } bool has_alpha(const string &str) { return find_if(str.begin(), str.end(), [](char c){return isalpha(static_cast(c));}) != str.end(); } } const char * hey(const char input[]) { string str(input); trim_spaces(str); if (str.empty()) return "Fine. Be that way!"; if (has_alpha(str) && str == to_uppercase(str)) return "Whoa, chill out!"; if ('?' == str.back()) return "Sure."; return "Whatever."; } }