Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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
29 changes: 20 additions & 9 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,52 @@
#include <ctime>
#include <vector>
#include <cctype>
#include <algorithm>

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 <string> VALIDATION = {"Cool","Great","Perfect","Beautiful","Aw, yeah"};
const vector<string> VALIDATION = {"Cool", "Great", "Perfect", "Beautiful", "Aw, yeah"};

string get_input_in_lowercase();

int main(){
int main()
{
string input;
int pick;

srand(time(0));
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;
}