by noobgrammer on Tue Oct 13, 2009 1:01 pm
Ok here you go with it working
- Code: Select all
#include<iostream>
#include<string>
#include<windows.h>
using namespace std;
int main()
{
char letter = NULL;
bool ab = false;
bool cd = false;
bool ef = false;
bool gh = false;
bool ij = false;
bool kl = false;
bool mn = false;
cout <<"lets play hangman\n\n";
Sleep(1000);
cout <<"guess what this word is.. _ _ _ _ _ _\n";
do{
cin>>letter;
switch(letter)
{
case'a':
cout<<"there is no _a_ in this word\n";
break;
case'c':
cout<<"there is no _c_ in this word\n";
break;
case'd':
cout<<"there is no _d_ in this word\n";
break;
case'e':
cout<<"congratulation there is an e \n";
kl = true;
break;
case'f':
cout<<"there is no _f_ in this word\n";
break;
case'g':
cout<<"there is no _g_ in this word\n";
break;
case'h':
cout<<"there is no _h_ in this word\n";
break;
case'i':
cout<<"there is no _i_ in this word\n";
break;
case'j':
cout<<"there is no _j_ in this word\n";
break;
case'l':
cout<<"there is no _l_ in this word\n";
break;
case'm':
cout<<"\ncongratulation there is an m\n";
ab =true;
break;
case'n':
cout<<"congratulation there is an n\n";
ef=true;
break;
case'o':
cout<<"congratulation there is an o\n";
cd = true;
break;
case'p':
cout<<"there is no _p_ in this word\n";
break;
case'q':
cout<<"there is no _q_ in this word\n";
break;
case'r':
cout<<"congratulation there is an r\n";
mn =true;
break;
case's':
cout<<"congratulation there is an s\n";
gh = true;
break;
case't':
cout<<"congratulation there is an t\n";
ij= true;
break;
case'u':
cout<<"there is no _u_ in this word\n";
break;
case'v':
cout<<"there is no _v_ in this word\n";
break;
case'w':
cout<<"there is no _w_ in this word\n";
break;
case'x':
cout<<"there is no _x_ in this word\n";
break;
case'y':
cout<<"there is no _y_ in this word\n";
break;
case'z':
cout<<"there is no _z_ in this word\n";
}
}while( cd != true || ab != true || ef != true || gh != true || ij != true || kl != true || mn != true);
cout<<"you win";
//system("pause");
return 0 ;
}
you where not using the do...while quite right its one do to one while so the others where just whiles.
you could probably get away without putting the whole alphabet down and only have the one's necessary by putting the (letter) inside a cout saying that is not it and only checking for the right one
I need a compiler with a can of RAID built into it
I added a msn messenger just for programming feel free to email or add yourself to it