protected override void IsWinner() { Card pickedCard = null; string hintMessage; int guesses = int.Parse(lblGuesses.Text); int sumOfPickedCard = 0; _guessTheCard = new GuessTheCard(_mysteryCard); foreach (Card guessCard in _deckToPick) { if (cbPickDeck.SelectedItem != null) { if (cbPickDeck.SelectedItem.ToString() == guessCard.ToString()) { hintMessage = _guessTheCard.CardHints(guessCard); lblHint.Text = hintMessage; pickedCard = _guessTheCard.GuessCard(guessCard); sumOfPickedCard = _guessTheCard.GetSumOfCards(); } } } if (_guessTheCard.IsWinner(sumOfPickedCard)) { lblMysteryCard.Text = _mysteryCard.ToString(); DialogResult result = MessageBox.Show("You are a winner! \nWould you like to play again?", "Guess The Card Result", MessageBoxButtons.YesNo); switch (result) { case DialogResult.Yes: StartGame(); break; case DialogResult.No: Close(); break; } } else if (guesses == 4) { lblGuesses.Text = "5"; lblMysteryCard.Text = _mysteryCard.ToString(); DialogResult result = MessageBox.Show("You are a loser! \nWould you like to play again?", "Guess The Card Result", MessageBoxButtons.YesNo); switch (result) { case DialogResult.Yes: StartGame(); break; case DialogResult.No: Close(); break; } } else { _deckToPick.Discard(pickedCard); ShowCards(); guesses++; lblGuesses.Text = guesses.ToString(); } }
public void CardHintsString() { Card guessCard = new Card(Rank.Three, Suit.Spades); Card mysteryCard = new Card(Rank.Three, Suit.Spades); GuessTheCard card = new GuessTheCard(mysteryCard); Assert.AreEqual("Three is correct and Spades is correct!", card.CardHints(guessCard)); }