Your instructor will assign you one of the problems below. To solve your problem, write a program that reads the necessary information to compute and output the indicated values, as efficiently as possible. Following the pattern in the lab exercise, first, design using OCD; then code your design in C++ using stepwise translation; finally, test your program thoroughly.
Project #12.1: Extend yourGender
enumeration with these operations:Write a driver program that tests your functions.
Next(Gender value);
that returns the enumerator that followsvalue
, wrapping around from the last valid enumerator to the first valid enumerator---returnsFEMALE
whenvalue
isUNKNOWN
, returnsMALE
whenvalue
isFEMALE
, and returnsUNKNOWN
whenvalue
isMALE
.Previous(Gender value);
that returns the enumerator that precedesvalue
, wrapping around from the first valid enumerator to the last valid enumerator---i.e., returnsFEMALE
whenvalue
isMALE
, returnsMALE
whenvalue
isUNKNOWN
, and returnsUNKNOWN
whenvalue
isFEMALE
.
Project #12.2: Build aMonth
enumeration. Using it, create aDate
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).
Project #12.3: Extend the classes inenumGenerator.cpp
to automatically generate theNext()
andPrevious()
functions described in the previous project for any enumeration.
Project #12.4: Build two enumerations:
- Suit, containing the values Clubs, Diamonds, Hearts and Spades.
- 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 andvector
, build aDeckOfCards
class. Provide the following operations:Use these classes to write a program that plays a simple card game, such as "Go Fish."
- A constructor that creates a new (in-order) deck of cards.
- A
Shuffle()
operation that arranges thePlayingCard
s in aDeckOfCards
in random order.- A
TopCard()
operation that returns the top card in theDeckOfCards()
without removing it.- A
DealTopCard()
operation that returns the top card in theDeckOfCards()
and removes it.
Turn the following things: