diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..3bcda02 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,13 @@ +name: C++ Build + +on: + push: + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Compile + run: g++ main.cpp -o autovalidate \ No newline at end of file diff --git a/main.cpp b/main.cpp index c9679c7..6726c43 100644 --- a/main.cpp +++ b/main.cpp @@ -3,19 +3,21 @@ #include #include #include +#include -using std::cout; using std::cin; +using std::cout; using std::endl; using std::string; -using std::vector; using std::transform; +using std::vector; -const vector VALIDATION = {"Cool","Great","Perfect","Beautiful","Aw, yeah"}; +const vector VALIDATION = {"Cool", "Great", "Perfect", "Beautiful", "Aw, yeah"}; string get_input_in_lowercase(); -int main(){ +int main() +{ string input; int pick; @@ -23,21 +25,30 @@ int main(){ pick = rand() % VALIDATION.size(); cout << "What are you listening to?\n"; input = get_input_in_lowercase(); + if (input == "nothing") + { + return 0; + } cout << VALIDATION[pick] << "! Let's listen to more\n"; - do{ + do + { cout << "What's next?\n"; input = get_input_in_lowercase(); + if (input == "nothing") + break; pick = rand() % VALIDATION.size(); cout << VALIDATION[pick] << "!\n"; - }while( input != "nothing" ); + } while (input != "nothing"); return 0; } -string get_input_in_lowercase(){ +string get_input_in_lowercase() +{ string in; - getline(cin,in); - transform(in.begin(), in.end(), in.begin(), [](unsigned char c){ return std::tolower(c); }); + getline(cin, in); + transform(in.begin(), in.end(), in.begin(), [](unsigned char c) + { return std::tolower(c); }); return in; } \ No newline at end of file