/** *@return true if user guessed a letter correctly *@return false if user guessed incorectly */ bool Hangman::guessedL(){ guessed.push_back(guessedLetter); changeWord(); if (hangManWord.find(guessedLetter) == string::npos) { wrongGuesses++; return false; } return true; }
void engine(char mysteryWord[], char *cat) { int Length = strlen(mysteryWord); int lifeLost = 0; int occurances = 0; int wrongCharOccurances = 0; char input = '\n'; // made to \n so it will be ignored in the first loop char HiddenWords[wordLength * 2] = "";// Initialize all to 0 char wrongChars[11] = ""; //InitializeArray(wrongChars,11); hideWord(Length,mysteryWord, HiddenWords); while (lifeLost < 10 && contains(HiddenWords, '_', Length * 2) > 0) { printScreen(lifeLost, cat, mysteryWord, HiddenWords, wrongChars); scanf("\n%c", &input); // /n*c added so that new line char is ignored when enter button is pressed if (lifeLost < 10 && input != '\n') { occurances = contains(mysteryWord, input, Length); // check if users guess is right wrongCharOccurances = contains(wrongChars,input,Length); //check if user has had the same guess before if(wrongCharOccurances == 0) // if user has not entered input before { if (occurances == 0) // If input is a wrong answer { wrongChars[lifeLost] = input; lifeLost = lifeLost + 1; } else { changeWord(mysteryWord, HiddenWords, input,Length); } } } } if (lifeLost == 10) { printScreen(lifeLost, cat, mysteryWord, HiddenWords, wrongChars); printf("You Lose!"); } else { printScreen(lifeLost, cat, mysteryWord, HiddenWords, wrongChars); printf("You Win!\n"); } }
HunspellDialog::HunspellDialog(QWidget *parent, ScribusDoc *doc, StoryText *iText) { setupUi( this ); setModal( true ); connect (ignoreOncePushButton, SIGNAL(clicked()), this, SLOT(goToNextWord())); connect (ignoreAllPushButton, SIGNAL(clicked()), this, SLOT(ignoreAllWords())); connect (changePushButton, SIGNAL(clicked()), this, SLOT(changeWord())); connect (changeAllPushButton, SIGNAL(clicked()), this, SLOT(changeAllWords())); connect (languagesComboBox, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(languageComboChanged(const QString &))); m_doc=doc; m_docChanged=false; m_iText=iText; m_returnToDefaultLang=false; m_primaryLangIndex=0; m_dictionaryMap = 0; m_hspellerMap = 0; m_wfList = 0; m_wfListIndex = 0; }