Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Name Galgenmännchen.cpp
- Zweck Spiel Galgenmännchen
- Datum 05.06.18
- Name der Programmierer JK/JS
- */
- #include <iostream>
- #include <vector>
- #include <string>
- #include <conio.h>
- using namespace std;
- vector<string>screen;
- vector<string>wort;
- void einlesen(int &len,bool &win)
- {
- len = 0;
- string eingabe;
- char c;
- cin.clear();
- cout << "Bitte ein Wort eingeben" << endl;
- cout << "Bestaetige die Eingabe mit 'ENTER'" << endl;
- while ((c = _getch()) != 13)
- {
- cout << "*";
- eingabe =+ c;
- if (eingabe[0] >= 65 && eingabe[0] <= 90 || eingabe[0] >= 97 && eingabe[0] <= 122)
- {
- wort.push_back(eingabe);
- screen.push_back(eingabe);
- len++;
- eingabe.erase();
- win = false;
- }
- else
- {
- win = true;
- eingabe.erase();
- break;
- }
- }
- system("cls");
- }
- void anzeige()
- {
- }
- void untersuchen(int len, bool &win)
- {
- bool troll = false;
- if (win == true)
- {
- }
- else
- {
- win = false;
- }
- string eingabe;
- int MaxVer = 15;
- int versuche = 0;
- if (len == 0)
- {
- win = true;
- }
- if (win == false)
- {
- while (versuche < MaxVer)
- {
- if (wort == screen)
- {
- win = true;
- }
- else{
- troll = false;
- cout << "Bitte einen Buchstaben eingeben" << endl;
- for (int i = 0; i < len; i++)
- {
- cout << screen[i] << " ";
- }
- cout << endl;
- cin >> eingabe;
- if (eingabe[0] >= 65 && eingabe[0] <= 90 || eingabe[0] >= 97 && eingabe[0] <= 122)
- {
- for (int i = 0; i < len; i++)
- {
- if (wort[i] == eingabe)
- {
- screen[i] = wort[i];
- troll = true;
- }
- }
- }
- else
- {
- troll = true;
- cout << "Alter nur Buchstaben" << endl;
- cout << "Versuch das lieber nochmal" << endl;
- system("pause");
- }
- eingabe.erase();
- system("cls");
- if (troll == false)
- {
- cout << "Das war falsch du Flasche!" << endl;
- cout << "Du hast noch " << MaxVer - versuche - 1 << " Versuche frei" << endl;
- versuche++;
- }
- }
- if (versuche == MaxVer)
- {
- system("cls");
- cout << "STIRB" << endl;
- }
- if (win == true)
- {
- versuche = MaxVer;
- cout << "Geschafft haett ich von dir Lappen nicht erwartet" << endl;
- }
- }
- }
- else
- {
- cout << "ERROR : Versuchs am besten nochmal" << endl;
- cout << "Du darfst nur Buchstaben eingeben man sonst nix" << endl;
- }
- }
- void striche(int len)
- {
- string q;
- q = '_';
- for (int i = 0; i < len; i++)
- {
- screen[i] = q;
- }
- }
- int main(){
- int len;
- bool win;
- char Nochmal = 'n';
- do
- {
- einlesen(len, win);
- striche(len);
- untersuchen(len, win);
- cout << "Nochmal?(j/n)" << endl;
- cin.clear();
- cin >> Nochmal;
- wort.clear();
- screen.clear();
- system("cls");
- }
- while (Nochmal == 'J' || Nochmal == 'j');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement