Exemplo n.º 1
0
        // Button click operation for evidence locations
        private void Guess_Click(object sender, EventArgs e)
        {
            guessCount++;

            int[] coords = GetButtonLocation(sender);
            Guess guess  = new Guess(coords[0], coords[1]);
            var   button = (Button)sender;

            if (scanalyzer.EvaluateGuess(guess, guessCount))
            {
                found++;
                CluesFnd_Label.Text = found.ToString();
                button.Text         = "X";
            }
            else
            {
                GuessCnt_Label.Text = guessCount.ToString();
                button.Text         = scanalyzer.GenerateHint(guess, guessCount);
            }
        }
Exemplo n.º 2
0
        // Display if user found clue or not
        public bool EvaluateGuess(Guess guess, int guessCount)
        {
            string notFound     = "Clue NOT Found ...";
            string notCaption   = "Try Again!";
            string found        = "Clue found ...";
            string foundCaption = "Good job!";

            //Not found
            if (!isMatch(guess, clue))
            {
                MessageBox.Show(notFound, notCaption,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                return(false);
            }
            else // Was found
            {
                MessageBox.Show(found, foundCaption,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);

                return(true);
            }
        }
Exemplo n.º 3
0
 // Is the user guess == to clue
 private bool isMatch(Guess guess, Clue key)
 {
     return((guess.getX() == key.getX() && guess.getY() == key.getY()) ? true : false);
 }