firstly hi all,
i''d like to intrroduce myself. Im a new C++ programmer..hardly..but trying..so yes its frustrating with the error and syntax mainly. Anywayz, this is a card game with 2 classes and simple functions but im having a problem compiling it. I compile it on visual studio so i hope you use the same one.so this is my problem:
not sure with the deal() and the showdeck() method and can't solve the errors...
#include<iostream>
#include<cstdlib>
using namespace std;
class Card
{
public: enum Suite
{
diamond,
club,
heart,
spade
};
int Value;
Suite Type;
};
class Deck
{
public:
Card deck[52];
Deck() //default constructor
{
for(int i=0;i<52;i++)
{
int q = i/13;
int r = i%13;
deck[i].Value = r;
if(q==0)
deck[i].Type = diamond;
else if(q==1)
deck[i].Type = club;
else if(q==2)
deck[i].Type = heart;
else if(q==3)
deck[i].Type = spade;
}
}
void shuffle()
{
//shuffle elements by going through the deck and swapping with another random position.
public:
for(int i=0;i<52;i++)
{
int r = i + (rand() % (52-i)); //random remaining positions
deck temp = deck[i]; //swap the values
deck[i] = deck[r];
deck[r] = deck temp;
}
}
void deal()
{
int t=0,p=0;
public:
const int N = 6;
Card hand1[N/2];
Card hand2[N/2];
private:
for(int i=0;i<N;i++)
{
if((N%2)==0)
{
hand1[t]=deck[i]; //even values of the deck are distributed to hand 1.
t++;
}
else
{
hand2[p]=deck[i]; //odd values of the deck are distributed to hand 2.
p++;
}
}
}
void showdeck()
{
cout<<"Player one has:\n";
while(s<(N/2))
{
cout<<hand1[s].Value;
cout<<hand1[s].Type\n;
s++;
}
cout<<"Player two has:\n";
while(s<(N/2))
{
cout<<hand2[s].Value;
cout<<hand2[s].Type\n;
s++;
}
}
};
void main()
{
Deck a;
a.shuffle; //4 tests to show 4 outputs of dealing through the whole card process.
a.deal;
a.showdeck;
a.shuffle;
a.deal;
a.showdeck;
a.shuffle;
a.deal;
a.showdeck;
a.shuffle;
a.deal;
a.showdeck;
}
can someone please help me.