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

Fix issues 68 89 #145

Open
wants to merge 2 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
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Build C++ Application

on:
pull_request:
branches:
- main
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install g++
run: sudo apt update && sudo apt install g++ -y

- name: Compile C++ code
run: g++ main.cpp --std=c++17 -o MyFave
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# MyFave

![Build Status](https://github.com/psajith03/MyFave/actions/workflows/ci.yml/badge.svg?branch=main)

This is a simple C++ command line application to maintain a list of your favorites.

## Getting Started
Expand All @@ -8,7 +10,7 @@ If you have not already built the image from `Dockerfile`, use the command:

```
docker build -t cpp-container .
```
```

You should only have to build once. Once built, run the container:

Expand Down
23 changes: 9 additions & 14 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -1,30 +1,25 @@
#include <iostream>
#include <vector>

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

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

vector<string> favorites;
cout << "At any time, type DONE to stop recording favorites.\n";

do
while (true)
{
if( favorites.size() == 0 )
cout << "What is your favorite?\n";

else
cout << "What is your next favorite?\n";

getline(cin,input);
if (favorites.empty()) cout << "What is your favorite?\n"; else cout << "What is your next favorite?\n";
getline(cin, input);
if (input == "DONE") break;
favorites.push_back(input);
}while( input != "DONE" );
}

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

return 0;
}