Visual Basic 2017 1. A deck of playing cards has 52 cards: A, 2, 3, 4, 5, 6, 7,
ID: 3830106 • Letter: V
Question
Visual Basic 2017
1. A deck of playing cards has 52 cards: A, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K in each suit of clubs, diamonds, hearts, and spades. In the game of 21, the player closest to 21 points without exceeding 21 wins. Cards 2 - 10 have their face value. J, Q, and K each count as 10 points. The A can be 1 or 11 as the player chooses. Each player is dealt 2 cards, then as much more as desired, one per turn.
2. You will play the game against the House plus three other players. Label five players as: House, player1, player2, player3, Me. Create a graphic for each card dealt consisting of a rectangle of proper color (clubs, spades = black; diamonds, hearts = red) with the identifying letter/number and suit in the rectangle. Each player should have the capacity for six cards.
3. Use a random number generator to generate each card dealt to a player. Note that the same card cannot be dealt twice. Below each player's cards include two radio buttons labeled "Hit" and "Stand". The house should not house the radio buttons, but instead, will stand if dealt "blackjack" (Ace plus 10-count card) in the first two cards, or when the House's point total is "hard" 17 (any Aces counted as 1) or above.
4. Thereafter, each player in order may select "Hit" for another card or "Stand" if no more cards are desired. Use a keystroke, or a button click, etc. to advance to the next player. A player should not be allowed to play out of turn however, the choice of "Stand" means a player receives no more cards for the balance of the hand. If a player's total points exceeds 21, your program announces "busted" and allows that player no more cards in that hand.
5. When all the players are done, your program should determine and announce the winner, or tie if one should exist, plus the score of the winning total for that hand.
(Please create a graphic and code for this project)
Explanation / Answer
#include 007 #include 008 #include 009 #include 010 using namespace std; 011 012 int suits[4]={1, 2, 3, 4}; 013 int faces[12]={1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; 014 015 016 class Card 017 { 018 public: 019 int face,suit; 020 Card(int face,int suit) 021 { 022 this->face=face; 023 this->suit=suit; 024 } 025 string toString() 026 { 027 string nameSuit; 028 string nameFace; 029 if (suit == 1) 030 nameSuit = "Hearts"; 031 else if(suit == 2) 032 nameSuit = "Diamonds"; 033 else if(suit == 3) 034 nameSuit = "Spades"; 035 else if (suit == 4) 036 nameSuit = "Clubs"; 037 038 if (face == 1) 039 nameFace = "Ace"; 040 else if(face == 10) 041 nameFace = "Jack"; 042 else if(face == 11) 043 nameFace = "Queen"; 044 else if(face == 12) 045 nameFace = "King"; 046 else { 047 for (int i = 2; i < 10; i++) 048 { 049 nameFace = "" + i; 050 } 051 052 return nameFace+" of "+nameSuit; 053 } 054 055 }; 056 057 class DeckOfCards 058 { 059 private: 060 vector deck; 061 int currentCard,index; 062 public: 063 DeckOfCards() 064 /*create deck*/ 065 { 066 currentCard=1; 067 for(int i=0;iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.