Skip to content

Instantly share code, notes, and snippets.

@soltys
Created May 29, 2011 18:20
Show Gist options
  • Save soltys/998004 to your computer and use it in GitHub Desktop.
Save soltys/998004 to your computer and use it in GitHub Desktop.
WordGenerator
#pragma once
#include <string>
#include <vector>
class WordGenerator
{
public:
virtual std::string generateNext();
std::string getCurrent();
WordGenerator(char* range)
{
createAlphabet(range);
firstLetter=*range;
lastLetter=*(alphabet.rbegin());
currentWord.push_back(firstLetter);
}
WordGenerator(char* range,std::string firstWord)
{
createAlphabet(range);
firstLetter=*range;
lastLetter=*(alphabet.rbegin());
currentWord = firstWord;
}
WordGenerator(void)
{
createAlphabet("a-zA-Z");
firstLetter = 'a';
lastLetter =*(alphabet.rbegin());;
currentWord = "a";
}
protected:
virtual void insertFrontCharacter(std::string& word);
std::string currentWord;
private:
std::vector<char> alphabet;
char firstLetter;
char lastLetter;
void createAlphabet(char* range);
char getNextLetterAlphabet(char after);
void WordGenerator::changeWord(std::string& word);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment