Course Home | Homework | Lab Open Hours | Programming | Schedule & Lecture Notes | Submit

Saint Louis University

Computer Science 180
Data Structures

Michael Goldwasser

Spring 2007

Dept. of Math & Computer Science

Programming Assignment 05

Cards

Due: Tuesday, 3 April 2007, 8pm
Wednesday, 4 April 2007, 8pm

Please see the general programming webpage for details about the programming environment for this course, guidelines for programming style, and details on electronic submission of assignments.

Collaboration Policy

For this assignment, you must work individually in regard to the design and implementation of your project.

Please make sure you adhere to the policies on academic integrity in this regard.


The files you may need for this assignment can be downloaded here.


Contents:


Overview

Your goal for this program will be to design a class Hand which will be used to simulate playing a game of cards. Every card will have a "suit" and a "value" specified. Your class must support the following routines:

For the routine insertCard(c), you may assume that the card is given with a valid suit and value. Furthermore, you do not need to worry about whether a new card is identical to an existing card. Just keep them both, as if they are two different cards. (In fact, those who have played Pinochle know that your hand may indeed have two cards with identical value and suit).

The semantics of the playDown(suit) routine is meant to model the rules of many common games (e.g., Hearts, Bridge, Pinochle) which require a player to "follow suit" when possible. Because of this requirement, players often find it convenient to organize their hand so that all cards of the same suit are consecutive in the hand (though the order of the suits, and the order of the cards within a particular suit may remain arbitrary).

A naive implementation for maintaining cards of the same suit grouped might still require a linear walk through the entire hand. When inserting a new card, one might have to walk from one end of the list until finding other cards of the same suit (or realizing that there are none). Similarly, when trying to play a card of a particular suit, one might have to scan the entire hand.

A better approach is to maintain four "fingers" into the hand, one for each suit, allowing insertions and deletions to be implemented in constant time (no matter how large the size of the hand becomes). You are required to implement this constant time approach based on the use of underlying std::list and its iterator class. A single list must be used to store all cards, and each "finger" will be represented by an iterator in that list.


Files We Are Providing

All such files can be downloaded here.

For this assignment, we will be providing you with a large number of needed files for a complete program, though you will not need to modify, or even read, many of them. We will briefly discuss the purpose of each file:


Requirements and Suggestions

In the end, meeting the requirements for this assignment can be easy. A perfect solution can be written concisely, at the same time, past students have submitted solutions in excess of 300 additional lines of code yet flawed.

Our real goal of this programming assignment is to give you familiarity with the official STL list class and the iterator class which it defines.

We have two strict requirements for this assignment.

The rest of the design details are left to your choice. We will add a few words of advice though.


Testing and Special Cases

We will again ask each student to submit a file "inputfile" which we will use in a round-robin competition. The assignment is worth 10 points. Eight points will be awarded based on our own evaluation of your assignment. One additional point will be awarded fractionally based on how well your program performs on other students' inputs. The final point will be awarded fractionally based on how well your input fools other students' programs.

You will find in developing your program that many different special case exists for this assignment. These range from how to represent a "finger" when a hand contains zero cards of a particular suit, as well as simply being careful in dealing with the NodeList interface in a way so that you do not end up with any unwanted exceptions.

Your file should be formatted perfectly to work as input to test_hand. You may use at most 100 commands, and you are not allowed to call the extra credit methods (as students are not required to implement these).


Files to Submit


Unfamiliar with Playing Cards?

If you are not familiar with cards or card games, do not worry. All that really matters for this assignment is that a card has a suit and a value, and the suit is the only piece of information which will effect your code. Feel free to ask if you have additional questions.


Grading Standards

The assignment is worth 10 points. Eight points will be awarded based on our own evaluation of your assignment and the readme file. One additional point will be awarded fractionally based on how well your program performs on other students' test inputs. The final point will be awarded fractionally based on how well your test input fools other students' flawed programs.


Michael Goldwasser
CSCI 180, Spring 2007
Last modified: Wednesday, 04 April 2007
Course Home | Homework | Lab Open Hours | Programming | Schedule & Lecture Notes | Submit