50 points Ideas: create a Card class with an internal \'Rank\' (A, 2, 3, 4, ..)
ID: 3697956 • Letter: 5
Question
50 points
Ideas:
create a Card class with an internal 'Rank' (A, 2, 3, 4, ..) and 'Suit' (spades, diamonds ...)
Here's one possible idea for a card class (Card.h)
#define CARD_H
#include <string>
using namespace std;
class Card
{
public:
Card();
// set and get the rank, 2=2, 3=3, ... 10=10, 11=J, 12=Q, 13=K, 14=A
void setRank(int r);
int getRank();
// set and get the suit, 1=Spades, 2=Hearts, ...
void setSuit(int r);
int getSuit();
// for debugging, print the suit and rand as integers
void print();
// return the rank and suit as a 'nice' looking string
string toString();
// if you want to use sort() in the STL
bool operator<(const Card &c) const {return myRank < c.myRank;}
private:
int myRank;
int mySuit;
};