Advertisement
Guest User

Untitled

a guest
Nov 29th, 2016
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.75 KB | None | 0 0
  1. //HEADER
  2.  
  3. #ifndef playingProcess_hpp
  4. #define playingProcess_hpp
  5.  
  6. #include <stdio.h>
  7. #include <iostream>
  8. #include <string.h>
  9. #include <ctype.h>
  10. #include <vector>
  11. #include <sstream>
  12.  
  13. using namespace std;
  14.  
  15. class playingProcess{
  16.    
  17. public:
  18.     void begin(string word);
  19.     void printBaseOfWord(int, string);
  20.     void enterLetter(vector<string>, string);
  21. };
  22.  
  23. #endif /* playingProcess_hpp */
  24.  
  25.  
  26.  
  27. //CLASS
  28.  
  29. #include "playingProcess.hpp"
  30. using namespace std;
  31.  
  32. vector<string> usedLetters(27, "0"); //USED LETTERS
  33. int counter(0); //COUNTS LETTERS INPUTED
  34.  
  35.  
  36. void playingProcess::begin(string word){
  37.     cout << word << endl;
  38.     printBaseOfWord(word.length(), word);
  39. }
  40.  
  41. void playingProcess::printBaseOfWord (int lenght, string word){
  42.     vector<string> hidenWord(lenght, "_");
  43.    
  44.     for (auto i = hidenWord.begin(); i != hidenWord.end(); ++i)
  45.         std::cout << *i << ' ';
  46.     enterLetter(hidenWord, word);
  47. }
  48.  
  49. void playingProcess::enterLetter(vector<string> arr, string word) {
  50.     cout << "Say the letter:" << endl;
  51.     char letter;
  52.     cin.get(letter);
  53.    
  54.     vector<char>vWord(word.begin(), word.end());
  55.      
  56.         for(int i = 0; i < 27; i++){
  57.             if(usedLetters[i] == letter){
  58.                 cout << "Guess another letter! This one is used." << endl;
  59.             } else {
  60.                 usedLetters[counter]=letter;
  61.                 counter++;
  62.                 vector<char>vWord(word.begin(), word.end());
  63.                 auto it = find(vWord.begin(), vWord.end(), *letter);
  64.                 if (it != vWord.end())
  65.                 {
  66.                     size_t index = std::distance(vWord.begin(), it);
  67.                     cout << index << endl;
  68.                 }
  69.                
  70.             }
  71.         }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement