2024-09-27 14:24:49 +02:00

50 lines
1.5 KiB
C++

#include <iostream>
#include <string>
#include "hangman.h"
using std::string;
int main() {
// Word the player needs to guess (randomly selected)
string word = chooseWord();
// Initialise the "uncovered" word that is shown to the player: the uncovered
// word is obtained by replacing each letter from the original word (variable
// word) with an underscore (i.e. _).
string workingCopy = createWorkingCopy(word);
// This variable indicates whether or not the game is over
bool done = false;
int wrongGuesses = 0; // Number of wrong guesses
int maxWrongGuesses = 6; // Maximum number of wrong guesses (don't change)
// Draw the empty gallow
showHangman(0);
// Game loop (each iteration is a round of the game)
while (!done) {
printGameState(maxWrongGuesses, wrongGuesses);
printWorkingCopy(workingCopy);
/** Part 1: input next guess **********************************************/
char guess = '\0';
// TODO: replace the following line with your implementation
PART1_readCharacter(guess);
/** Part 2: update working copy *******************************************/
bool found = false;
// TODO: replace the following line with your implementation
PART2_updateWorkingCopy(word, guess, workingCopy, found);
/** Part 3: update game state *********************************************/
// TODO: replace the following line with your implementation
PART3_updateGameState(word, workingCopy, found, maxWrongGuesses, done, wrongGuesses);
}
return 0;
}