Hello, I'm new to C++ and I am currently learning it for my course. We have been set the task of creating and displaying a deck of cards. The brief for the assignment states that I must use a class.
A card will have the following operations: Constructor that takes two arguments; an integer and a string. Function to return the suit attribute. Function to return the value attribute.
"I expect the Ace, Jack, Queen and King values to displayed as strings but stored as integers."
As we are all new to C++, most of the class (college class, not c++ class) are pretty confused about how to go about it.
This is what I have so far. (C++ hasn't worked itself into my head that well yet) We are using Code Blocks to write our programmes.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
#include <iostream>
#include <string>
using namespace std;
class Card
{
private:
string Suit;
int Num;
public:
Card(int s, int n)
{
Suit = s;
Num = n;
}
};
#include <iostream>
#include "class.cpp"
using namespace std;
int main()
{
int Deck[52], x, y;
for (x=0;x<4;x++)
{
for (y=0;y<13;y++)
{
switch (y)
{
case 0: ; break;
case 1: ; break;
case 2: ; break;
case 3: ; break;
case 4: ; break;
case 5: ; break;
case 6: ; break;
case 7: ; break;
case 8: ; break;
case 9: ; break;
case 10: ; break;
case 11: ; break;
case 12: ; break;
}
switch (x)
{
case 0: ; break;
case 1: ; break;
case 2: ; break;
case 3: ; break;
}
}
}
return 0;
}
|
Obviously there is a lot missing. I would be very grateful if somebody could give me some pointers without straight up what to do as I would like to work out mostly how to do it myself.
Sorry if what I've said isn't clear, and feel free to tell me what I've got so far is wrong :)