Advertisement
Guest User

2 nices Programm

a guest
Jun 21st, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.82 KB | None | 0 0
  1. /*
  2. Name Galgenmännchen.cpp
  3. Zweck Spiel Galgenmännchen
  4. Datum 05.06.18
  5. Name der Programmierer JK/JS
  6. */
  7.  
  8.  
  9. #include <iostream>
  10. #include <vector>
  11. #include <string>
  12. #include <conio.h>
  13. using namespace std;
  14.  
  15. vector<string>screen;
  16. vector<string>wort;
  17.  
  18.  
  19.  
  20. void einlesen(int &len,bool &win)
  21. {
  22. len = 0;
  23. string eingabe;
  24. char c;
  25. cin.clear();
  26. cout << "Bitte ein Wort eingeben" << endl;
  27. cout << "Bestaetige die Eingabe mit 'ENTER'" << endl;
  28. while ((c = _getch()) != 13)
  29. {
  30. cout << "*";
  31. eingabe =+ c;
  32. if (eingabe[0] >= 65 && eingabe[0] <= 90 || eingabe[0] >= 97 && eingabe[0] <= 122)
  33. {
  34. wort.push_back(eingabe);
  35. screen.push_back(eingabe);
  36. len++;
  37. eingabe.erase();
  38. win = false;
  39. }
  40. else
  41. {
  42. win = true;
  43. eingabe.erase();
  44. break;
  45. }
  46.  
  47. }
  48. system("cls");
  49. }
  50. void anzeige()
  51. {
  52.  
  53.  
  54. }
  55.  
  56.  
  57. void untersuchen(int len, bool &win)
  58. {
  59. bool troll = false;
  60. if (win == true)
  61. {
  62. }
  63. else
  64. {
  65. win = false;
  66. }
  67. string eingabe;
  68. int MaxVer = 15;
  69. int versuche = 0;
  70. if (len == 0)
  71. {
  72. win = true;
  73. }
  74. if (win == false)
  75. {
  76. while (versuche < MaxVer)
  77. {
  78. if (wort == screen)
  79. {
  80. win = true;
  81. }
  82. else{
  83. troll = false;
  84. cout << "Bitte einen Buchstaben eingeben" << endl;
  85. for (int i = 0; i < len; i++)
  86. {
  87. cout << screen[i] << " ";
  88. }
  89. cout << endl;
  90. cin >> eingabe;
  91. if (eingabe[0] >= 65 && eingabe[0] <= 90 || eingabe[0] >= 97 && eingabe[0] <= 122)
  92. {
  93. for (int i = 0; i < len; i++)
  94. {
  95. if (wort[i] == eingabe)
  96. {
  97. screen[i] = wort[i];
  98. troll = true;
  99. }
  100. }
  101. }
  102. else
  103. {
  104. troll = true;
  105. cout << "Alter nur Buchstaben" << endl;
  106. cout << "Versuch das lieber nochmal" << endl;
  107. system("pause");
  108. }
  109. eingabe.erase();
  110. system("cls");
  111. if (troll == false)
  112. {
  113. cout << "Das war falsch du Flasche!" << endl;
  114. cout << "Du hast noch " << MaxVer - versuche - 1 << " Versuche frei" << endl;
  115. versuche++;
  116. }
  117.  
  118. }
  119. if (versuche == MaxVer)
  120. {
  121. system("cls");
  122. cout << "STIRB" << endl;
  123. }
  124. if (win == true)
  125. {
  126. versuche = MaxVer;
  127. cout << "Geschafft haett ich von dir Lappen nicht erwartet" << endl;
  128. }
  129.  
  130. }
  131. }
  132. else
  133. {
  134. cout << "ERROR : Versuchs am besten nochmal" << endl;
  135. cout << "Du darfst nur Buchstaben eingeben man sonst nix" << endl;
  136. }
  137. }
  138.  
  139.  
  140.  
  141.  
  142. void striche(int len)
  143. {
  144.  
  145. string q;
  146. q = '_';
  147. for (int i = 0; i < len; i++)
  148. {
  149. screen[i] = q;
  150. }
  151.  
  152. }
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159. int main(){
  160. int len;
  161. bool win;
  162. char Nochmal = 'n';
  163. do
  164. {
  165. einlesen(len, win);
  166.  
  167. striche(len);
  168.  
  169. untersuchen(len, win);
  170.  
  171. cout << "Nochmal?(j/n)" << endl;
  172.  
  173. cin.clear();
  174.  
  175. cin >> Nochmal;
  176.  
  177. wort.clear();
  178.  
  179. screen.clear();
  180.  
  181. system("cls");
  182.  
  183. }
  184.  
  185. while (Nochmal == 'J' || Nochmal == 'j');
  186. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement