question archive This is the methods but I cant seem to get it right without some errors
Subject:Computer SciencePrice: Bought3
This is the methods but I cant seem to get it right without some errors.
The following methods are required for the Card class. They should all be public.
void setCard( int newFace, const char newSuit[] )
This method sets both the face and the suit for the Card object. It takes two arguments: an integer that represents the new face value for the card and a character array that represents the new suit value for the card. It returns nothing.
Error checking is required. The integer data member should have a value between 1 and 13, inclusive. If the passed in integer value is within the required range (1-13), use it to change the face data member. Otherwise, change the face data member to 1.
The character array data member should contain "Clubs", "Diamonds", "Hearts", or "Spades". Use the strcmp function to check the passed in character array argument. If the value is one of the possible suit values, use the strcpy function to copy it into the suit data member. Otherwise, use the strcpy function to change the suit data member to "Hearts".
int getFace()
This accessor method returns the face value of the Card. It takes no arguments and returns an integer.
const char * getSuit()
This accessor method returns the suit value of the Card. It takes no arguments and returns a pointer to a constant character.
This method should simply return the name of the character array data member. Assuming the character array data member is named suit, the code for the method should be:
const char * Card::getSuit() { return suit; }
void displayCard()
This method displays a text version of the Card. It takes no arguments and returns nothing.
For the face value, if the value is:
So if a Card object has a face value of 6 and suit value of "Hearts",
6 of Hearts
should be displayed. Or if a Card object has a face value of 12 and suit value of "Clubs",
Queen of Clubs
should be displayed.