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

Quiz 1 #43

Closed
wants to merge 7 commits into from
Closed
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
18 changes: 18 additions & 0 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: C++ CI

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


jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: install dependencies
run: sudo apt install -y build-essential
- name: Compile C++ 2017
run: g++ main.cpp -std=c++17 -o Wordler
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ Then play the game:
./wordler
```

The game will randomly-select a 5-letter word and you have unlimited guesses to get the word right. Each time you guess, if you have a letter that matches the same location as it is in the secret word, it will be revealed to you. However, any letter that does *not* match the secret word's letter at the same location will be displayed as `_`. Good luck!
The game will randomly-select a 5-letter word and you have unlimited guesses to get the word right. Each time you guess, if you have a letter that matches the same location as it is in the secret word, it will be revealed to you. However, any letter that does *not* match the secret word's letter at the same location will be displayed as `_`. Good luck!

[![C++ CI](https://github.com/reembot/Wordler/actions/workflows/actions.yml/badge.svg)](https://github.com/reembot/Wordler/actions/workflows/actions.yml)
9 changes: 6 additions & 3 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,23 @@ int main(){
// require user to enter another guess if their word isn't 5 letters long
do{
std::cin >> guess;
}while( guess.length() != 5 );
}while( guess.length() != 5 && guess != "quit");

// capitalize guess for easy comparisons
capitalize(guess);
guesses++;
hint = capitalize(get_hint(guess,secret));
hint = get_hint(guess,secret);
capitalize(hint);

if( hint == secret ){
std::cout << "Congrats, you got it in " << guesses << " guesses!\n";
} else if (guess == "quit") {
break;
}
else{
std::cout << hint << " Guess again: ";
}
}while( guess != secret );
}while( guess != secret && guess != "quit");


return 0;
Expand Down