Project 0 - War Card game

# Project 0 - War Card game - Robert J England II COS 221...

This preview shows pages 1–5. Sign up to view the full content.

Robert J. England II COS 221 Project 0 War Card Game Project done for Prof. Larry Latour Monday, September 25, 2006

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
} ostream & operator // POST: The information about a card is printed // to the screen, and the original ostream is // returned. { // first output rank switch (aCard.rank) { case 1: out << "Ace" ; break ; case 11: out << "Jack" ; break ; case 12: out << "Queen" ; break ; case 13: out << "King" ; break ; default : // output number out << aCard.rank; break ; } // then output suit switch (aCard.suit) { case diamond: out << " of Diamonds" ; break ; case spade: out << " of Spades" ; break ; case heart: out << " of Hearts" ; break ; case club: out << " of Clubs" ; break ; } return out; } class randomInteger { public : unsigned int operator () ( unsigned int ); // POST: A random integer between 0 and max is returned. // The same sequence of integers is returned every runtime. } randomizer; unsigned int randomInteger:: operator () ( unsigned int max) // POST: A random integer between 0 and max is returned. // The same sequence of integers is returned every runtime. { unsigned int rval = rand(); return rval % max; } class Deck { public : // constructor Deck ( ); // POST: A standard, unshuffled deck of 52 cards is created. // operations void shuffle ( ) // PRE: The deck is still full // POST: The deck is randomly shuffled { random_shuffle (cards, cards+52, randomizer); } bool isEmpty ( ) // POST: True is returned if the deck is empty; otherwise // false is returned { return topCard <= 0; }

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Card draw ( ); // PRE: The deck must still have cards. // POST: If the deck still has cards left, the top card is
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 14

Project 0 - War Card game - Robert J England II COS 221...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online