Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //HEADER
- #ifndef playingProcess_hpp
- #define playingProcess_hpp
- #include <stdio.h>
- #include <iostream>
- #include <string.h>
- #include <ctype.h>
- #include <vector>
- #include <sstream>
- using namespace std;
- class playingProcess{
- public:
- void begin(string word);
- void printBaseOfWord(int, string);
- void enterLetter(vector<string>, string);
- };
- #endif /* playingProcess_hpp */
- //CLASS
- #include "playingProcess.hpp"
- using namespace std;
- vector<string> usedLetters(27, "0"); //USED LETTERS
- int counter(0); //COUNTS LETTERS INPUTED
- void playingProcess::begin(string word){
- cout << word << endl;
- printBaseOfWord(word.length(), word);
- }
- void playingProcess::printBaseOfWord (int lenght, string word){
- vector<string> hidenWord(lenght, "_");
- for (auto i = hidenWord.begin(); i != hidenWord.end(); ++i)
- std::cout << *i << ' ';
- enterLetter(hidenWord, word);
- }
- void playingProcess::enterLetter(vector<string> arr, string word) {
- cout << "Say the letter:" << endl;
- char letter;
- cin.get(letter);
- vector<char>vWord(word.begin(), word.end());
- for(int i = 0; i < 27; i++){
- if(usedLetters[i] == letter){
- cout << "Guess another letter! This one is used." << endl;
- } else {
- usedLetters[counter]=letter;
- counter++;
- vector<char>vWord(word.begin(), word.end());
- auto it = find(vWord.begin(), vWord.end(), *letter);
- if (it != vWord.end())
- {
- size_t index = std::distance(vWord.begin(), it);
- cout << index << endl;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement