#include <conio.h>
#include <iostream>
#include <stdio.h>
#include <windows.h>
#include "F:\helper.h"
#include <cmath>
#include <vector>
using namespace std;
//Function Declarations------------------------------
void start();
void guesses();
//---------------------------------------------------
string word;
int amtGuesses;
char i;
int num=1;
int index=0;
//----------------------------------------------------
int main()
{
clrscr();
//-----------------------------
start();
guesses();
//-----------------------------
cout << endl << endl << "PRESS ANY KEY TO EXIT" << endl;
getch();
clrscr();
return(0);
}
//Function Definitions---------------------------------------------
void start()
{
cout<<"Enter your secret word"<<endl;
cin>>word;
clrscr();
cout<<"The secret word has "<<word.length()<<" letters"<<endl;
cout<<"press enter"<<endl;
getch();
clrscr();
}
void guesses()
{
vector<char>guess(word.length());
int correct=0;
int wrong=0;
int pos=1;
int index=0;
int k=0;
string letters;
string guessed;
do
{
for(i=0;i<word.length();i++)
{
cout<<"*";
}
for (i=0;i<word.length();i++);
{
cout<<" Enter your guess for position "<<pos<<"."<<endl;
gotoxy(0,0);
cout<<letters;
cin>>guess[i];
guessed=guessed+guess[i];
}
if(guess[i]==word[index])
{
cout<<"Correct"<<endl;
index++,correct++,pos++;
letters=letters+guess[i];
cout<<"Press enter to continue"<<endl;
getch();
clrscr();
}
else
{
wrong++;
cout<<"Incorrect. You have "<<wrong<<" wrong guesses out of 6."<<endl;
cout<<"Press enter to continue"<<endl;
getch();
clrscr();
}
if(correct==word.length())
{
cout<<"You WIN"<<endl;
cout<<"The word was "<<word<<"."<<endl;
getch();
clrscr();
break;
}
if(wrong==1&&k==0)
{
cout<<"O"<<endl;
k++;
cout<<"Press enter";
getch();
clrscr();
}
if(wrong==2&&k==1)
{
cout<<" O"<<endl;
cout<<"/"<<endl;
k++;
cout<<"Press enter";
getch();
clrscr();
}
if(wrong==3&&k==2)
{
cout<<" O"<<endl;
cout<<" / \\"<<endl;
k++;
cout<<"Press enter";
getch();
clrscr();
}
if(wrong==4&&k==3)
{
cout<<" O"<<endl;
cout<<"/ | \\"<<endl;
k++;
cout<<"Press enter";
getch();
clrscr();
}
if(wrong==5&&k==4)
{
cout<<" O"<<endl;
cout<<"/ | \\"<<endl;
cout<<" /"<<endl;
k++;
cout<<"Press enter";
getch();
clrscr();
}
if(wrong==6&&k==5)
{
cout<<"You have gotten the max amount of guesses wrong. The correct word was "<<word<<"."<<endl;
gotoxy(0,0);
cout<<" O"<<endl;
cout<<"/ | \\"<<endl;
cout<<" / \\"<<endl;
k++;
cout<<"Press enter";
getch();
clrscr();
}
}while(wrong<6);
}
//-----------------------------------------------------------------
Ok all I need is to make it so when I guess a letter, it will apply that letter to any position in the word of the equation. So if the word was "Dead" if I typed in D it would look like this "D--D". And also If it could be made so that it stored the letters guessed that are WRONG, so you cant guess them again. THANK YOU FELLOW PROGRAMMERS!
Edited by WingedPanther, 02 November 2009 - 09:18 AM.
add code tags ( the # button)


Sign In
Create Account

Back to top









