
Patrick B. answered 05/24/21
Math and computer tutor/teacher
Suit getSuit(const string& s) //turns a string like "Spade" or "Heart" into an enumerated value
{
Suit suitReturn;
if (s=="Heart" || s=="HEART" || s=="heart")
{
suitReturn = HEART;
}
else if (s=="Diamond" || s=="DIAMOND" || s=="diamond")
{
suitReturn=DIAMOND;
}
else if (s=="Club" || s=="CLUB" || s=="club")
{
suitReturn=CLUB;
}
else if (s=="Spade" || s=="SPADE" || s=="spade")
{
suitReturn = SPADE;
}
return(suitReturn);
}
string getSuitName(Suit s) /* given an enumerated value, returns the corresponding string.
Hint: the SUIT_NAMES array can help make this a one-line function. */
{
return (SUIT_NAMES[s]); //INDEED!
}