关于简单的刽子手游戏双字母的问题。 [英] Question about double letters in simple hangman game.

查看:100
本文介绍了关于简单的刽子手游戏双字母的问题。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确信这个问题已经出现了一两次,但我没有找到类似的问题或答案,所以如果这是一个双重帖子我道歉。



我在C#的控制台应用程序中编写了一个完整的刽子手游戏,我已经完成了所有工作(是小写字母t),但为了完全完成它并完成了T.

我似乎有双字母的问题。

例如,GOOD或MISSISSIPPI。

它会查看信件的第一个实例,但只会看到它。

有什么想法吗?



再次感谢大家的帮助。



我有什么尝试过:



我将迭代单词数组并计算猜出的字母弹出的次数。

I am sure this question has popped up a time or two, but I haven't found a like question or answer so I apologize if it's a double post.

I wrote a full hangman game in the console application in C#, and I have everything working to a t (yes a lower case t) but in order to completely finish it and be finished to a T.
I seem to have a problem with double letters.
for example, "GOOD", or "MISSISSIPPI".
it looks at the first instance of the letter, but only ever looks at that.
Any ideas?

Thanks again for everyone's help.

What I have tried:

I was going to iterate through the word array and count how many times the guessed letter pops up like.

int d = 0;
foreach(char ch in wordArray)
{
   if(guessedLetter == ch)
     {
       d++;
     }
}





然后我意识到它也不会允许我放同样的字母在空白部分。这个工作似乎真的不需要,但我无法在任何地方找到答案。



but then I realized that it's not going to also allow me to put the same letter in the blanks section. And that work around just seems really un-needed but I can't find an answer anywhere.

推荐答案

如果是我,因为用户猜出每个字母,我'从wordArray的(开头)删除该字母,然后将其附加到一个新单词Array.



那时,你需要做的就是检查wordArray的第一个元素是否是正确的字母,当wordArray为空时游戏就解决了。
If it was me, as the user guesses each letter, I'd remove the letter from the (beginning of the) wordArray, and append it to a new word Array.

At that point, all you'd have to do is check the first element of wordArray to see if it's the right letter, and the game is solved when wordArray is empty.


这篇关于关于简单的刽子手游戏双字母的问题。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆