Click here to Skip to main content
15,942,710 members
Home / Discussions / C#
   

C#

 
Questionhow to have Pin
jojoba201113-Mar-14 19:14
jojoba201113-Mar-14 19:14 
AnswerRe: how to have Pin
BillWoodruff13-Mar-14 23:00
professionalBillWoodruff13-Mar-14 23:00 
AnswerRe: how to have Pin
Pete O'Hanlon13-Mar-14 23:11
mvePete O'Hanlon13-Mar-14 23:11 
QuestionRe: how to have Pin
jojoba201113-Mar-14 23:23
jojoba201113-Mar-14 23:23 
AnswerRe: how to have Pin
Eddy Vluggen13-Mar-14 23:30
professionalEddy Vluggen13-Mar-14 23:30 
AnswerRe: how to have Pin
Pete O'Hanlon13-Mar-14 23:57
mvePete O'Hanlon13-Mar-14 23:57 
AnswerRe: how to have Pin
Ravi Bhavnani14-Mar-14 6:41
professionalRavi Bhavnani14-Mar-14 6:41 
QuestionHelp Please Pin
Member 1045276713-Mar-14 10:38
Member 1045276713-Mar-14 10:38 
Hi im not sure if I can ask for help here, my appolagise if not I will remove if required to.

I am stuck however with a hangman style game I am building, Simply a word pulls from file at random and the output to the user is '*' symbols instead of the letters, the user can select to guess a letter from the keyboard etc... The program does cross ref the guess with the actual word and if the user guesses correctly it will replace the '*' with the correct letter, the issue is it will only do one loop so wont allow for continuation until the word is complete. I would appreciate any help with this so that the user keeps going until the word is completed. Many Thanks. Here is the code:

private void chckGss_Func(string wordToGuess)
{
StringBuilder showUser = new StringBuilder(fileWord.Length);
for (int i = 0; i < fileWord.Length; i++)
showUser.Append('*');

List<char> goodGuess = new List<char>();
List<char> badGuess = new List<char>();
int lives = 5;
bool win = false;
int charReveal = 0;
string inpt;
char guess;

while (!win && lives > 0)
{
inpt = tmpLttr.ToUpper();
guess = inpt[0];

if (goodGuess.Contains(guess))
{
btnCorrect.Visible = true;
lblCorrect.Visible = true;
continue;
}

else if (badGuess.Contains(guess))
{
btnWrong.Visible = true;
lblWrong.Visible = true;
continue;
}

if (wrd2GuessUpper.Contains(guess))
{
goodGuess.Add(guess);

for (int i = 0; i < fileWord.Length; i++)
{
if (wrd2GuessUpper[i] == guess)
{
showUser[i] = fileWord[i];
charReveal++;
}
}

if (charReveal == fileWord.Length)
win = true;

}
else
{
badGuess.Add(guess);
lives--;
return;
}

txtWrdToGuess.AppendText(showUser.ToString());
}

if (win)
MessageBox.Show("You win!");
else
MessageBox.Show("You lose, the word was " + fileWord);
}
AnswerRe: Help Please Pin
Richard Andrew x6413-Mar-14 11:33
professionalRichard Andrew x6413-Mar-14 11:33 
GeneralRe: Help Please Pin
Member 1045276713-Mar-14 23:35
Member 1045276713-Mar-14 23:35 
QuestionDLL Existance Test Pin
Stephen Wickland13-Mar-14 8:08
Stephen Wickland13-Mar-14 8:08 
AnswerRe: DLL Existance Test Pin
Eddy Vluggen13-Mar-14 8:39
professionalEddy Vluggen13-Mar-14 8:39 
GeneralRe: DLL Existance Test Pin
Stephen Wickland13-Mar-14 9:25
Stephen Wickland13-Mar-14 9:25 
AnswerRe: DLL Existance Test Pin
Abhinav S15-Mar-14 21:35
Abhinav S15-Mar-14 21:35 
QuestionRead Excel C# windows form using OleDB Connection Pin
Zeyad Jalil12-Mar-14 23:08
professionalZeyad Jalil12-Mar-14 23:08 
AnswerRe: Read Excel C# windows form using OleDB Connection Pin
Bernhard Hiller13-Mar-14 1:10
Bernhard Hiller13-Mar-14 1:10 
GeneralRe: Read Excel C# windows form using OleDB Connection Pin
Zeyad Jalil13-Mar-14 1:56
professionalZeyad Jalil13-Mar-14 1:56 
AnswerRe: Read Excel C# windows form using OleDB Connection Pin
Richard MacCutchan13-Mar-14 2:20
mveRichard MacCutchan13-Mar-14 2:20 
GeneralRe: Read Excel C# windows form using OleDB Connection Pin
Zeyad Jalil13-Mar-14 2:26
professionalZeyad Jalil13-Mar-14 2:26 
GeneralRe: Read Excel C# windows form using OleDB Connection Pin
Richard MacCutchan13-Mar-14 2:44
mveRichard MacCutchan13-Mar-14 2:44 
AnswerRe: Read Excel C# windows form using OleDB Connection Pin
OriginalGriff13-Mar-14 2:59
mveOriginalGriff13-Mar-14 2:59 
GeneralRe: Read Excel C# windows form using OleDB Connection Pin
Eddy Vluggen13-Mar-14 3:59
professionalEddy Vluggen13-Mar-14 3:59 
GeneralRe: Read Excel C# windows form using OleDB Connection Pin
OriginalGriff13-Mar-14 4:51
mveOriginalGriff13-Mar-14 4:51 
QuestionCalling through modem to mobile phone Pin
Akshay41112-Mar-14 1:43
Akshay41112-Mar-14 1:43 
AnswerRe: Calling through modem to mobile phone Pin
jschell12-Mar-14 11:14
jschell12-Mar-14 11:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.