
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

Card games have been very popular applications to program. One thing these applications have in common is that they all have to create and manipulate deck(s) of playing cards. In this assignment you are asked to implement a "Card" C++ class, and write a test program that creates a deck of cards and perform shuffling of the deck of cards. Use the following files from the ~ lam/274/lab3 subdirectory in your program: card.h : a header file that specifies all interfaces that pertain to this class. card.cpp : a partial implementation of the Card class and two functions declared in card.h lab3.cpp : a skeleton of the test program that you would have to complete. INPUT : None OUTPUT : The deck will be output twice, one before and one after the deck is shuffled. The value of a card should show the face value (A for Ace, 2 for Two, , T for Ten, J for Jack, Q for Queen, K for King), followed by the suit (C for Club, D for Diamond, H for Heart, S for Spade.) For example, a Five of Heart should be displayed as 5H. REQUIREMENTS : You must use the enum suitType and faceType for the suit and face value of a card in your program. DO NOT use integer or any other types for representing card values. Use a random number generator (need to use the rand() and srand() functions from stdlib.h and the time() function from time.h) to implement the shuffleDeck function. Add only what is required in the lab3.cpp , card.h and card.cpp files. The implementation of the overloaded ++ operators and the Card operations must be done in a separate file named card.cpp. The overloaded ++ operator for suitType is already provided in the card.cpp file. Do the following: Copy files lab3.cpp , card.h , and card.cpp from the ~ lam/274/lab3 subdirectory into your 274/lab subdirectory and use them as the basis and complete the program as required. Document your program following the Program Documentation Guide which may be accessed through http://www.cecs.csulb.edu/~lam/cecs274/course-notes.html. (Replace all existing comments that are designed as instructions.) Compile, link and run your program using the C++ compiler in UNIX (GNU C++) as follows: a) g++ -c card.cpp This command compiles card.cpp into an object file card.o b) g++ -c lab3.cpp This command compiles lab3.cpp into an object file lab3.o c) g++ -o lab3 lab3.o card.o This command links the two object files and creates an executable file lab. d) lab3 Type this command to run the program Create a file named makefile in your 274/lab3 subdirectory with the following content ([TAB] means press the TAB key): lab3: lab3.o card.o [TAB]g++ -o lab3 lab3.o card.o lab3.o: lab3.cpp card.o [TAB]g++ -c lab3.cpp card.o: card.h card.cpp [TAB]g++ -c card.cpp Each time after a file is modified, type the make command to prompt UNIX to do all necessary recompilation. And you only need to type lab3 to execute your program if there is no compile-time error. Turn in a copy of your complete source code and the output of a test run. Demo your program on the due date. Demo must be done with the UNIX make command. Shui Lam (Spring 2003)