# Commputer programming (poker card game)

FratBro23
Category:
Programming
Price: \$50 USD

Question description

Requirements:  This is a project-oriented assignment, which will be the lab coding work for the remainder of the course.  Create a manually played game, in particular, a poker card game is suggested, and code samples will be provided for programming a card game.

Lab 8:

1. Create a 1D array of String to store a deck of cards.  Use the following scheme to store the cards:  “VS”

Where V is Value and S is suit.  For example, AS would be Ace of Spades, 4D would be 4 of Diamonds, QH would be Queen of Hearts, TC would be 10 of Clubs (use T for 10).  So for face cards, A-Ace, K-King, Q-Queen, J-Jack, T-Ten.  The Diamond cards would be 2D, 3D, 4D, 5D, 6D, 7D, 8D, 9D, TD, JD, QD, KD, AD.  Initialize the deck String array in the code with the { , , } initializer list.  Optional to read from a file, but not necessary.

1. Ask the user how many players n (1-7)
2. Print the unshuffled deck, then shuffle the deck by generating two random numbers between 0 and 51, and swapping the elements in those two array locations, at least 100 times.
3. Deal 7-Card-Stud to n players (need 49 cards for 7 players) into a 7x7 array called hands[][].  Use a counter to access the deck[] array from 0 to (7*n)-1, while setting up a nested loop to iterate over n players (rows) and 7 columns.
4. Rules:  No betting.  No drawing.  Just deal the cards all at once into the hands[][] array, using the # of rows needed for each player (1-7) and all 7 columns.  Note:  use 7, 14, 21, 28, 35, 42 or 49 elements depending on # of players.
5. Show the current state of the deck (all 52 cards) and the hands for the players.
6. Determine if a flush exists for each hand (use 4 counters).  A flush is a hand with 5 or more of the same suit.  You can compare a particular item in the hand array as such:

if (hand[p][c].charAt(1) == ‘C’) ++cCount;  // where p is player, c is card, and do this for each suit

1. Some of the variables which will be needed:  String [] deck;  String [][] hands;  int numPlayers;  loop counter variables;  other counters such as int cCount, dCount, sCount, hCount;  // these would be used as counters for clubs, diamonds, spades, hearts.  Remember to initialize them to 0 before processing the hand.

Alternate to 7-Card Stud:  create a simple game that uses arrays and methods (functions).  For example, Craps, Blackjack, Yahtzee, etc.  You can also do a simple simulation of a sport.

7-Card Stud Sample Output:

Please enter # of players:  2

Unshuffled Deck:  (Note:  print in 4 rows using modulus, for example:  if ( (n+1) %13 ) System.out.println(); )

2H 3H 4H 5H 6H 7H 8H 9H TH JH QH KH AH

2S ….

2D ….

2C ….

Shuffled Deck:  (Note:  include all 52 cards, print in 4 rows like unshuffled deck)

7D  AC  8C  KD  KS  TH  QD  5S  2S  JD  7H  2H  JD  5C ..  ..  ..  ..

Player 1 Hand:

7D 8C KS QD 2S 7H JD

Player 2 Hand:

AC KD TH 5S JD 2H 5C

(Top Tutor) Daniel C.
(997)
School: UIUC
Studypool has helped 1,244,100 students

1830 tutors are online

### Related Programming questions

Brown University

1271 Tutors

California Institute of Technology

2131 Tutors

Carnegie Mellon University

982 Tutors

Columbia University

1256 Tutors

Dartmouth University

2113 Tutors

Emory University

2279 Tutors

Harvard University

599 Tutors

Massachusetts Institute of Technology

2319 Tutors

New York University

1645 Tutors

Notre Dam University

1911 Tutors

Oklahoma University

2122 Tutors

Pennsylvania State University

932 Tutors

Princeton University

1211 Tutors

Stanford University

983 Tutors

University of California

1282 Tutors

Oxford University

123 Tutors

Yale University

2325 Tutors