CSE 332 Lab 2: Card Decks and Hands

Due by Tuesday March 3 at 11:59 pm (deadline for receipt of e-mail with solution zip file)
Final grade percentage: 8 percent

Objective:

This lab is intended to extend your use of basic C++ language features from the previous labs, and to make more extensive use of c++ classes and structs. To do this, you will extend your C++ programs from the previous labs to (1) encapsulate groups of cards within formal hand objects, (2) encapsulate groups of cards within formal deck objects, (3) "shuffle" the cards in a deck object, (4) "deal" cards from decks into hands, and (5) rank hands according to scoring functions that are defined outside the hand class. In this lab and in the subsequent labs, you are encouraged to re-use and modify code from your previous lab solutions - if you choose do this, please put a completely new copy of any header and source files from your previous lab(s) in the new lab project directory you create. This can avoid some potential for error or confusion within Visual Studio, and also ensures you have a backup copy that you could go back to if a modification you try doesn't pan out.

Assignment:

    Part I - Readings:

  1. The following readings in the course text book and reference web pages may be useful as reference material while working on this lab assignment, and selectively looking up topics and/or reading ahead (on demand as you encounter issues while working on the lab) is also encouraged:

  2. Please read the following CSE 332 Programming Guidelines which relevant to the previous labs and please follow them as you implement your solution: A.1-A.17, B.1, B.2, B.10-B.13, B.15-B.17, B.20-B.25, B.28, B.29, B.31-B.33, and C.1-C.8.

    Please also review and follow one additional guideline that may be relevant to this lab: B.18 (copy constructor and assignment operator).

    Part II - Program Design and Implementation:

    Note: the details of this assignment are again intentionally somewhat under-specified, leaving you some room to choose what you think is the best way to implement them, as long as what you do is reasonable and you explain your design decisions in comments in the code and in your Readme.txt file.

  3. Open up Visual Studio 2013, and create a new Win32 Console Application Visual C++ project for lab 2.
  4. Declare and define a class (e.g., of type Deck) to represent a deck of cards, with a private member variable that is an STL-supplied random access sequence container containing the card type you created in your previous labs (e.g., of type vector<Card> but not list<Card>). The public interface for this deck class should be:

  5. Declare and define a class (e.g., of type Hand) to represent a card player's hand of cards. This class should have a private member variable that is an STL-supplied container of cards (e.g., of type vector<Card> or list<Card>). The public interface for this class should be:

  6. Declare and define a "poker_rank" function that takes two references to const hand objects and returns a bool value that is true if (and only if) the first hand object ranks higher than the second hand object in the poker hand ranking definition given in the extra credit portion of the previous lab assignment.

  7. In your project's main function:

  8. Build your project, and fix any errors or warnings that occur. Please be sure to note all of the different kinds of errors or warnings you ran into (though you don't have to list every instance of each kind) in your ReadMe.txt file. If you were fortunate enough not to run into any errors or warnings, please note that instead, where you would have listed errors or warnings in your ReadMe.txt file.

  9. Open up a Windows console (terminal) window and change to the directory where your program's executable file was created by Visual Studio.

  10. Run the executable program through a series of trials that test it with good coverage of cases involving both well formed and badly formed inputs. For this lab one especially useful test is to check whether the output printed by your program consistently represents the contents of the input files it was given. In your ReadMe.txt file please document which cases you ran (i.e., what the command lines were) and summarize what your program did and whether that is correct behavior, in each case.

  11. In your ReadMe.txt file, make sure that your name and the lab number (lab 2) are at the top of the file, and that you've documented whether you ran into any errors or warnings while developing your solution (and if so what they were) and what the executable program did for each of the trials you ran. Be sure to save your changes to your ReadMe.txt file, as well as those to your source (and header) file(s) before preparing your solution zip file.

  12. Prepare a zip file that contains your project's source, header, and ReadMe.txt files (but not a built executable, or stdafx.h, stdafx.cpp or other Windows-generated files you did not modify, etc.), by:

    Send the zip file containing your lab 2 solution as an e-mail attachment to the course e-mail account (cse332@seas.wustl.edu) so that it arrives by the submission deadline for this assignment. If you need to make changes to your lab solution you are welcome to send a new zip file, and we will grade the latest one received prior to the deadline (according to the receipt time stamp the server puts on the e-mail).

    Part III - Code structure and style: (optional, worth up to 5% extra credit)

    The goal of this optional part of the assignment is to have you take a deeper look at the programming guidelines, and to think about and describe their intent and relevance in your program. While an additional level of documentation is required for this extra credit portion, all labs will be evaluated for conformance to the specific CSE 332 Programming Guidelines noted at the top of this assignment. Please ask for help from your professor or teaching assistants if you are uncertain about how to do this extra credit part or if you run into any difficulty with it.

  13. In your readme file, please add a section clearly marked "extra credit" and in it explain for each of the following groups of CSE 332 Programming Guidelines (1) which ones do or do not apply to your lab solution (and why or why not), and for those that do apply (2) explain how you followed (or how and why you deviated from) them:


Posted 4pm Wednesday February 11 2015 by
Chris Gill