diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..df76d02 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,24 @@ +name: Build C++ Project + +on: + push: + branches: [ main, develop ] + pull_request: + branches: [ main ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: code compile test + uses: actions/checkout@v4 + + - name: Install g++ + run: sudo apt-get update && sudo apt-get install -y g++ + + - name: Compile project + run: g++ main.cpp --std=c++17 -o MyFave + + - name: Run executable (optional) + run: ./MyFave diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cba7efc --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +a.out diff --git a/README.md b/README.md index 121b94d..07377a6 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # MyFave +[![Build C++ Project](https://github.com/bincent0929/vr-MyFave/actions/workflows/main.yml/badge.svg?branch=main&event=status)](https://github.com/bincent0929/vr-MyFave/actions/workflows/main.yml) + This is a simple C++ command line application to maintain a list of your favorites. ## Getting Started diff --git a/main.cpp b/main.cpp index f455fcf..ad1ab72 100644 --- a/main.cpp +++ b/main.cpp @@ -5,27 +5,32 @@ using std::cout, std::cin, std::endl, std::string, std::vector; int main() { - string input = ""; + string input; vector favorites; cout << "At any time, type DONE to stop recording favorites.\n"; - do + bool first_run = true; + while (input != "DONE") { - if( favorites.size() == 0 ){ - cout << "What is your favorite?\n"; + if (first_run == false) { + favorites.push_back(input); } - else{ - cout << "What is your next favorite?\n"; + else { + first_run = false; } + + if( favorites.size() == 0 ) + cout << "What is your favorite?\n"; + else + cout << "What is your next favorite?\n"; + getline(cin,input); - favorites.push_back(input); - }while( input != "DONE" ); + } cout << "Your favorite list:\n"; - for(int i = 0; i < favorites.size() -1; i++){ + for(int i = 0; i < favorites.size(); i++) // whole list printed cout << favorites.at(i) << endl; - } return 0; } \ No newline at end of file