View Single Post
Old 04-02-2005, 05:28 PM   #1 (permalink)
marina
Hottie
 
marina's Avatar
 
Join Date: Apr 2005
Posts: 5
marina is on a distinguished road
Question NEED HELP on card assignment

I'm just a beginner in C++ and need some help . My assignment is the following:

You must implement a function that initializes the deck of cards. The internal storage of a single card is defined below:

enum SuiteType {SPADE, CLUB, HEART, DIAMOND};
struct Card
{
int value;
SuiteType suite;
};

Your function should be called generate_deck() and must initialize an array of 52 cards to the appropriate values using loops. Do not initialize this array by hand! Once you are finished with this function please test your results.

Deck array element: 0 ...1...2...3...4...5...6...7...8....9...10...11... 12
SPADE .................A....2...3...4...5...6...7...8... 9...10...J.....Q.....K

Deck array element: 13..14..15..16..17..18..19..20...21..22..23..24..2 5
CLUB .....................A....2...3....4....5...6....7 ...8....9...10....J...Q....K

Deck array element: 26..27..28..29..30..31..32..33..34...35..36..37..3 8
HEART ...................A....2...3....4....5....6...7.. ..8 ...9...10...J....Q....K

Deck array element: 39..40..41..42..43..44..45..46..47..48..49..50..51
DIAMOND ...............A....2...3 ...4 ...5...6....7 ...8 ...9..10...J ..Q ..K


I know there is a nested loop I should use because the card value changes while the suit stays the same for 13 times then it goes to the next suit. I think using a for loop and case.

Please help if you may!

Last edited by marina; 04-30-2005 at 01:55 PM.
marina is offline   Reply With Quote