Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add input handling, add continous integration, fixes #1, fixes #2 #42

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
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
23 changes: 23 additions & 0 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Build C++

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
install:
runs-on: ubuntu-latest
steps:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y -f build-essential g++ cmake
build:
needs: install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build project
run: g++ main.cpp -std=c++17 -o MyFave
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ docker run -it cpp-container sh
docker run -v "$(pwd)":/usr/src -it cpp-container
```

[![Build C++](https://github.com/natesmitty1738/MyFave/actions/workflows/actions.yml/badge.svg)](https://github.com/natesmitty1738/MyFave/actions/workflows/actions.yml)
18 changes: 11 additions & 7 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
#include <iostream>
#include <vector>
#include <string>

using std::cout, std::cin, std::endl, std::string, std::vector;

int main(){
string input = "";
vector<string> list;
vector<string> favorites;

do{
if( list.size() == 0 ){
if( favorites.size() == 0 ){
cout << "What is your favorite?\n";
}
else{
cout << "What is your next favorite?\n";
}
cin >> input;
list.push_back(input);
getline(cin, input);
if (input != "done"){
favorites.push_back(input);
}

}while( input != "done" );

cout << "Your favorite list:\n";
for(int i = 0; i < list.size(); i++){
cout << list.at(i) << endl;
cout << "Your favorite favorites:\n";
for(int i = 0; i < favorites.size(); i++){
cout << favorites.at(i) << endl;
}

return 0;
Expand Down