Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // KCM @ KCM @ KCM
- #include <iostream>
- #include <vector>
- using namespace std;
- int main()
- {
- char again='y'; //(do you want to play?)
- vector<char>word;
- vector<char>mystery;
- vector<char>guessed;
- while(again=='y'||again=='Y')
- {
- char letter='0';
- int one=1;
- int j=0;
- int count=0;
- int left;
- int guesses=0;
- int chances=6;
- int disc=0;
- cout<<"Type in any word or words, followed by '@'\n"; //sets up the word
- while(letter!='@')
- {
- cin>>letter;
- if(letter!='@')
- {
- word.push_back(letter);
- ++j;
- }
- }
- left=j; //# of letters
- cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\nletters: "<<j<<"\n\n\n\n\n\n\n"; //shows how many letters there are total
- while(left>0&&chances>0)
- {
- cout<<"\n\nChances left: "<<chances<<"\n\n\n"; //prints chances left
- count=0;
- if(chances==6)
- cout<<" ___\n | |\n |\n |\n |\n ___ \n | |\n\n\n";
- else if(chances==5)
- cout<<" ___\n | |\n O |\n |\n |\n ___ \n | |\n\n\n";
- else if(chances==4)
- cout<<" ___\n | |\n O |\n I |\n |\n ___ \n | |\n\n\n";
- else if(chances==3)
- cout<<" ___\n | |\n O |\n I |\n / |\n ___ \n | |\n\n\n";
- else if(chances==2)
- cout<<" ___\n | |\n O |\n I |\n // |\n ___ \n | |\n\n\n";
- else if(chances==1)
- cout<<" ___\n | |\n O |\n |I |\n // |\n ___ \n | |\n\n\n";
- while(count<j) //prints dashes and correct letters
- {
- mystery.push_back('_');
- cout<<mystery[count]<<" ";
- ++count;
- }
- count=0;
- cout<<"\n\n\nGuess a letter: "; ///guess time
- cin>>letter;
- while(one==2)
- {
- one=1;
- for(int i=0;i<guesses;++i)
- {
- if(letter==guessed[i])
- {
- one=2;
- cout<<"\nYou already guessed that.\n\nGuess another letter: ";
- cin>>letter;
- }
- }
- }
- one=2;
- for(int i=0;i<j;++i) //controls replacing blanks with letters, as well as counts how many chances there are left
- {
- if(letter==word[i])
- {
- mystery[i]=word[i];
- --left;
- disc=1;
- }
- }
- if(disc==0)
- {
- --chances;
- }
- disc=0;
- ++guesses;
- cout<<"\n\n\n\n\n\n\nGuessed: "; //prints guessed letters
- guessed.push_back(letter);
- while(count<guesses)
- {
- cout<<guessed[count];
- ++count;
- }
- count=0;
- }
- if(chances>0)
- cout<<"\n~~~~~~~~~~\nYou Win!!!\n\n'";
- else if(left>0)
- cout<<"\n\n\n~~~~~~~~~~\nYou Lose!!!\n\n ___\n | |\n X |\n |I| |\n // |\n ___ \n | |\n\n\n'";
- while(count<j)
- {
- cout<<word[count];
- ++count;
- }
- cout<<"'\n\nWould you like to play again? (Y/N): ";
- cin>>again;
- while(again!='Y'&&again!='y'&&again!='N'&&again!='n')
- {
- cout<<"'\nWould you like to play again? (Y/N): ";
- cin>>again;
- }
- cout<<"\n\n";
- }
- cout<<"Thanks for playing!\n\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement