CSE 332 Lab 3: Dictionaries, Tile Collections, and Permutations

Lab dates: Wednesday September 30, Wednesday October 7, and Wednesday October 14, 2009
Due by Tuesday October 20 at 11:59 pm (deadline for e-mailing a zip file with your solution)
Final grade percentage: 10 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. To do this, you will extend your C++ programs from the previous labs to (1) move randomly selected tiles from one collection of tiles to another, (2) generate all permutations of a collection of tiles, (3) check each permutation against the words in a dictionary, and (4) print out a list of the permutations that match in order from highest to lowest score.

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.

In the next lab assignment you will use these features to allow a user to play a text-based solitaire version of the game "scrabble", with a board on which interlocking words are played.

Assignment:

    Part I - Readings:

  1. The following readings in the optional text books and reference web pages may be useful as reference material while working on this lab assignment, and though we'll touch on most of the issues in the next few studio selectively looking up topics and/or reading ahead (on demand as you encounter issues while working on the lab) is also encouraged:

  2. The constructor, destructor, operator, accessor, and mutator method examples in the C++ classes lecture slides give an overview of class syntax and structure you may need for this lab.

  3. The STL algorithm examples in the C++ C++ functions, classes, and templates lecture slides also may be helpful when implementing parts this lab.

  4. 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.6, A.9-A.11, A.17, B.7, B.9, B.13, B.15, B.16, B.20-B.23, B.25, B.30, B.33, B.34, C.1-C.4 and C.6-C.9.

    Please also review and follow the additional guidelines that may be relevant to this lab: A.7-A.8 (exceptions), A.12-A.15 (pointers and arrays), A.16 (debugging), B.1-B.6 (dynamic memory allocation), B.10-B.12 (constructors), B.18 (copy constructor and assignment operator), B.22 first part (inclusion guards), and C.5 (pointer arithmetic).

    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.

  5. Open up Visual Studio, and create a new Win32 Console Application Visual C++ project for lab 3.
  6. Declare and define a class to represent a Dictionary) with a private member variable that is an STL-supplied container of C++ style strings (e.g., of type vector<string> or list<string>). The public interface for this class should be:

  7. Declare and define a class (e.g., of type LetterTileCollection) to represent a collection of letter tiles. This class should have a private member variable that is an STL-supplied container of letter tiles (e.g., of type vector<LetterTile> or list<LetterTile>). The public interface for this class should be:

  8. Declare and define a class (e.g., of type WordCollection) to represent the possible valid rearrangements of a collection of letter tiles that make up words that are found in a dictionary. This class should have a private member variable that is an STL-supplied container of letter tile collections (e.g., of type vector<LetterTileCollection> or list<LetterTileCollection>). The public interface for this class should be:

    Word collection objects should print out the permutations they contain in order by ascending score. How you implement this is up to you, but establishing the ordering in the constructor as an invariant is one nice way to do this.

    Please decide whether or not you want to implement (by declaring and defining a copy constructor and assignment operator for the class) or prevent (see programming guideline B.18) copying of Dictionary and WordCollection objects. In your ReadMe.txt file, please state and justify your decisions about this and please also describe how you tested whether or not your approach to this worked for both of those types.

  9. In your project's main function:

  10. 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.

  11. Open up a Windows console (terminal) window and change to the directory where your program's executable file was created by Visual Studio (see the first studio exercises document for more details on this, if you don't remember them).

  12. 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 valid dictionary and tile definition 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.

  13. In your ReadMe.txt file, make sure that your name and the lab number (lab 3) 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.

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

    Send the zip file containing your lab 3 solution as an e-mail attachment to the course e-mail account (cse332@cec.wustl.edu) 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 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.

  15. In your readme file, please add a section clearly marked "extra credit" and in it explain for each of the following sets 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:


Updated 10am Thursday October 8 2009 by
Chris Gill

Changes since original posting: