Beispiel #1
0
        private void Analysis(string hiddenword, string wordattempt)
        {
            wordattempt = wordattempt.ToLower();
            wordattempt = wordattempt.Replace('ё', 'е');

            moves += 1;
            bulls  = 0;
            cows   = 0;
            char[] letters_word    = Letters.hiddenword.ToCharArray();
            char[] letters_attempt = wordattempt.ToCharArray();


            for (int i = 0; i < letters_word.Length; i++)
            {
                for (int j = 0; j < letters_attempt.Length; j++)
                {
                    if (i == j && letters_word[i] == letters_attempt[j])
                    {
                        bulls          += 1;
                        letters_word[i] = '0';
                    }
                }
            }

            for (int i = 0; i < letters_word.Length; i++)
            {
                for (int j = 0; j < letters_attempt.Length; j++)
                {
                    if (i != j && letters_word[i] == letters_attempt[j])
                    {
                        cows           += 1;
                        letters_word[i] = '0';
                    }
                }
            }

            if (bulls == wordattempt.Length)
            {
                Win winpage = new Win();
                this.Close();
                winpage.ShowDialog();
            }
        }
Beispiel #2
0
        private void Analysis(string hiddenword, string wordattempt)
        {
            wordattempt = wordattempt.ToLower();
            wordattempt = wordattempt.Replace('ё', 'е');

            moves += 1;
            bulls = 0;
            cows = 0;
            char[] letters_word = Letters.hiddenword.ToCharArray();
            char[] letters_attempt = wordattempt.ToCharArray();

            for (int i = 0; i < letters_word.Length; i++)
            {
                for (int j = 0; j < letters_attempt.Length; j++)
                {
                    if (i == j && letters_word[i] == letters_attempt[j])
                    {
                        bulls += 1;
                        letters_word[i] = '0';
                    }
                }
            }

            for (int i = 0; i < letters_word.Length; i++)
            {
                for (int j = 0; j < letters_attempt.Length; j++)
                {
                    if (i != j && letters_word[i] == letters_attempt[j])
                    {
                        cows += 1;
                        letters_word[i] = '0';
                    }
                }
            }

            if (bulls == wordattempt.Length)
            {
                Win winpage = new Win();
                this.Close();
                winpage.ShowDialog();
            }
        }