course.wilkes.edu/CS125Labs
Welcome to the site for CS 125 labs!

 

Lab 11: Projects

Prev | Next | Lab 11

Objectives

1. Practice using enumerations.
2. Gain experience defining enumeration operations.

Introduction

Your instructor will tell you which one of the following projects to do.

Projects

11.1. Extend your Gender enumeration with these operations:

  • Next(Gender value); that returns the enumerator that follows value, wrapping around from the last valid enumerator to the first valid enumerator (i.e., returns FEMALE when value is UNKNOWN, returns MALE when value is FEMALE, and returns UNKNOWN when value is MALE.
  • Previous(Gender value); that returns the enumerator that precedes value, wrapping around from the first valid enumerator to the last valid enumerator (i.e., returns FEMALE when value is MALE, returns MALE when value is UNKNOWN, and returns UNKNOWN when value is FEMALE.
Write a driver program that tests your functions.

11.2. Build a Month enumeration. Using it, create a Date class that stores the month, day, and year for a date. Test your class by writing a program that reads two dates, and returns the number of days between those two dates (don't forget to consider leap years).

11.3. Extend the classes in enumGenerator.cpp to automatically generate the Next() and Previous() functions described in 11.1 for any enumeration.

11.4. Build two enumerations:

  • Suit, containing the values Clubs, Diamonds, Hearts and Spades; and
  • Rank, containing the values Ace, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King.
Use these enumerations to design and build a PlayingCard class. Using this class and vector, build a DeckOfCards class. Provide the following operations:
  • a constructor that creates a 'new' (in-order) deck of cards;
  • a Shuffle() operation that arranges the PlayingCards in a DeckOfCards in 'random' order;
  • a TopCard() operation that returns the "top" card in the DeckOfCards() without removing it; and
  • a DealTopCard() operation that returns the "top" card in the DeckOfCards() and removes it.
Use these classes to write a program that plays a simple card game, such as "Go Fish."

Turn In: A hard copy of

  1. all source files you created for this project; and
  2. the output from an execution of your executable program (using script).

Don't forget to clean up your directory when you are all finished...

Prev | Next | Lab 11

 
  Home

Help

Lab 0

Lab 1

Lab 2

Lab 3a

Lab 3b

Lab 4

Lab 5

Lab 6

Lab 7

Lab 8

Lab 9

Lab 10

Lab 11

Lab 12

Lab 13



Membership

Login




Last update: Friday, October 6, 2000 at 1:02:35 PM.
visitors to this page.