Chapter 12 Exercise Set 0: Chapter ReviewΒΆ
Create files named
Cards.h
andCards.cpp
to hold theCard
object developed in this chapter. In addition to a constructor, be sure to includeto_string
,equals
, andis_greater
member functions.Change the
Time::print
function we wrote in the print section to aTime::to_string
function that returns a string like we did forCard
objects in The to_string function.Rewrite the
equals
function from the The equals function section as a free-standing function that takes twoCard
s as arguments.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.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 ofCard
s.Add a
to_string
member function to theFraction
class you created in Chapter 11 Exercise Set 0: Chapter Review. It should return a string withnumerator/denominator
except when thedenomintor
is1
, in which case it should return only a string containing the numerator.