I have been racking my brain for a bit on this and just can't figure it out.
The book "Object-Oriented Programming C++" by Joyce Farrell pg382 exercise 13.
They're wanting me to make a class named "PlayingCard" that contains 4 fields which are values and suits in both numbered and string format and each is assigned these values on construction. So they're wanting a constructor that puts all of the cards in a fictional deck that is accessed through the PlayingCard?
They're also wanting the "Hand" Class to use a PlayingCard object that would be 5 different cards.
I am confused about how to make the connection/transistion into classes.
Here is what I have so far:
#include <iostream>
#include <string>
#include <ctime>
using namespace std;
const int SIZE = 5;
class PlayingCard
{
private:
int faceVal;
int suitVal;
public:
PlayingCard();
};
PlayingCard::PlayingCard()
{
string cardVal[] = {"","Ace","One","Two","Three","Four","Five","Six","Seven",
"Eight","Nine","Ten","Jack","Queen","King"};
string cardSuit[] = {"","Spade","Heart","Clubs","Diamonds"};
}
class Hand
{
public:
Hand();
int getCard(int);
};
Hand::Hand()
{
PlayingCard aHand[SIZE];
srand((unsigned)time(NULL));
}
int Hand::getCard(int card)
{
return card;
}
int main()
{
Hand playerHand[SIZE];
for(int x = 0; x < SIZE; ++x)
{
}
system("pause");
return 0;
};