Skip to content

Instantly share code, notes, and snippets.

bool Hangman::isAlpha(const QString& key)
{
if (alphabet.size() > 0)
{
return alphabet.contains(key.toUpper());
}
return false;
}
@zachelko
zachelko / ASCII-tricks.cpp
Created April 2, 2010 19:45
ASCII tricks
// Add letters to our vector using ASCII conversion (saves typing =p)
for (int i = 65; i < 91; i++)
{
char letter = static_cast<char> (i);
alphabet.push_back(QString(letter));
}
@zachelko
zachelko / findAllOccurances.cpp
Created April 2, 2010 19:39
findAllOccurrences
QList<int> Hangman::findAllOccurrences(const QChar& theChar, const QString& theStr)
{
QList<int> occurrences;
for (int i = 0; i < theStr.size(); i++)
{
if (theStr.at(i).toUpper() == theChar.toUpper())
{
occurrences.push_back(i);
}
}