Chapter 13 Exercise Set 1ΒΆ

  1. Create files named Cards.h and Cards.cpp to hold the Card object developed in this chapter. In addition to a constructor, be sure to include to_string, equals, and is_greater member functions.

  2. Change the Time::print function we wrote in the print section to a Time::to_string function that returns a string like we did for Card objects in The to_string function.

  3. Rewrite the equals function from the The equals function section as a free-standing function that takes two Cards as arguments.

  4. In the version of Card introduced in this chapter, aces are less than deuces (2s). Change this so that aces are ranked higher than Kings, as they are in most card games.

  5. Encapsulate the deck-building code from the Vectors of cards section in a function named build_deck that takes no arguments and that returns a fully-populated vector of Cards.

  6. Add a to_string member function to the Fraction class you created in Chapter 12 Exercise Set 1. It should return a string with numerator/denominator except when the denomintor is 1, in which case it should return only a string containing the numerator.