Created
May 29, 2011 18:20
-
-
Save soltys/998004 to your computer and use it in GitHub Desktop.
WordGenerator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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