本文整理汇总了C++中Boggle::getPlayerWords方法的典型用法代码示例。如果您正苦于以下问题:C++ Boggle::getPlayerWords方法的具体用法?C++ Boggle::getPlayerWords怎么用?C++ Boggle::getPlayerWords使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Boggle
的用法示例。
在下文中一共展示了Boggle::getPlayerWords方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: promptplayerInput
/**
* @brief promptplayerInput asks the player to type in a valid word
* @param boggle
*/
void promptplayerInput(Boggle& boggle){
Lexicon lex("EnglishWords.dat");
string tempWord;
cout << "It's your turn!" << endl;
printGrid(boggle);
printPlayerWords(boggle);
cout << "Your score: " << boggle.getPlayerScore() << endl;
cout << "Type a word (or press 1 to quit): ";
cin >> tempWord;
//makes the str uppercase
transform(tempWord.begin(), tempWord.end(),tempWord.begin(), ::toupper);
clearConsole();
while(tempWord != "1"){
printGrid(boggle);
if(!lex.contains(tempWord)){
cout << "Not a word in the dictionary" << endl;
}
else if (!(boggle.getPlayerWords().find(tempWord) != boggle.getPlayerWords().end())) {
cout << "Word already used" << endl;
}
else if ((tempWord.size() < 4)) {
cout << "Word is too small" << endl;
}
else if (!(boggle.findWordInGrid(tempWord))) {
cout << "That word can't be formed on this board." << endl;
}
else {
boggle.updateScore(tempWord);
boggle.insertplayerWord(tempWord);
}
printPlayerWords(boggle);
cout << endl;
cout << "Your score: " << boggle.getPlayerScore() << endl;
cout << "Type a word (or press 1 to quit): ";
cin >> tempWord;
clearConsole();
//makes the str uppercase
transform(tempWord.begin(), tempWord.end(),tempWord.begin(), ::toupper);
}
}
示例2: printPlayerWords
/**
* @brief printPlayerWords outputs the words that the player has found
* @param boggle
*/
void printPlayerWords(Boggle& boggle) {
set<string> playerWords = boggle.getPlayerWords();
cout << "Your words (" << playerWords.size() << "):";
for(set<string>::iterator it = playerWords.begin(); it != playerWords.end(); it++){
cout << *it << " ";
}
cout << endl;
}