//plays the end game scenario, playing the dealers role. public void Hold() { form.toggleButtons(); house_image_util.Unflip(0); while (Sum(house_hand) <= HOUSE_THRESHOLD && house_hand.currentCardCount() < TOTAL_CARDS_ALLOWED) { house_hand.drawCard(); house_image_util.Draw(); } if (Sum(house_hand) > TWENTY_ONE) { if (Sum(user_hand) == TWENTY_ONE) { MessageBox.Show("You got Blackjack!", "Blackjack Game", MessageBoxButtons.OK, MessageBoxIcon.None); } else { MessageBox.Show("House went bust, you win!", "Blackjack Game", MessageBoxButtons.OK, MessageBoxIcon.None); } } else { calculateScore(); } }
//generates a new card and give it to the player public void Hit() { user_hand.drawCard(); user_image_util.Draw(); if (Sum(user_hand) == TWENTY_ONE) { Hold(); } else if (Sum(user_hand) > TWENTY_ONE) { form.toggleButtons(); MessageBox.Show("You went bust, you lose.", "Blackjack Game", MessageBoxButtons.OK, MessageBoxIcon.None); } else if (user_hand.currentCardCount() >= TOTAL_CARDS_ALLOWED) { form.toggleButtons(); MessageBox.Show("You got a five-card Charlie, you win!", "Blackjack Game", MessageBoxButtons.OK, MessageBoxIcon.None); } }