diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..8789fda --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,28 @@ +name: CI Build + +on: + pull_request: + branches: + - main # + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Set up GCC + uses: actions/setup-java@v2 + + - name: Install build tools + run: sudo apt-get install build-essential + + - name: Compile the Application + run: g++ main.cpp --std=c++17 -o MyFave + + - name: Verify build success + run: ./MyFave \ + + #Commit error \ No newline at end of file diff --git a/README.md b/README.md index 121b94d..bdffb39 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +[![CI Build](https://github.com/EscGit/MyFave/actions/workflows/ci.yml/badge.svg)](https://github.com/EscGit/MyFave/actions/workflows/ci.yml) # MyFave This is a simple C++ command line application to maintain a list of your favorites. diff --git a/main.cpp b/main.cpp index 9cc1de5..d20b1f5 100644 --- a/main.cpp +++ b/main.cpp @@ -3,28 +3,32 @@ using std::cout, std::cin, std::endl, std::string, std::vector; -int main() -{ +int main(){ string input = ""; - vector favorites; + vector favorites; cout << "At any time, type DONE to stop recording favorites.\n"; do { - if( favorites.size() == 0 ) + if( favorites.size() == 0 ){ cout << "What is your favorite?\n"; - - else + } + else{ cout << "What is your next favorite?\n"; - + } + + }while( input != "DONE" ){ getline(cin,input); favorites.push_back(input); - }while( input != "DONE" ); + } + if (input == "DONE"){ cout << "Your favorite list:\n"; - for(int i = 0; i < favorites.size() -1; i++) - cout << favorites.at(i) << endl; + for(const auto& favorite : favorites) { + cout << favorite << endl; + } +} return 0; } \ No newline at end of file