-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcard.cpp
More file actions
executable file
·82 lines (81 loc) · 1.13 KB
/
card.cpp
File metadata and controls
executable file
·82 lines (81 loc) · 1.13 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <vector>
class card
{
public:
bool face;
int rank;
int type;
card(bool f,int r,int t)
{
face=f;
rank=r;
type=t;
}
card()
{
face=0;
rank=0;
type=0;
}
};
std::vector<card> dek(53);
class deck:public card
{
public:
void init();
void shuffle();
void throwCard();
void match();
void printCard(card ob);
void printDeck();
};
void deck::shuffle()
{
srand(time(NULL));
for(int i=1;i<53;i++)
{
int x=rand()%(i+1);
card temp=dek[i];
dek[i]=dek[x];
dek[x]=temp;
}
}
void deck::init()
{
int c=1;
for(int i=1;i<=4;i++)
{
for(int j=1;j<=13;j++)
{
card ob(0,j,i);
dek[c]=ob;
c++;
}
}
}
int main()
{
clrs();
deck player;
player.init();
for(int i=1;i<53;i++)
{
std::cout<<"-----CARD-----\n";
std::cout<<"face"<<dek[i].face<<"\n";
std::cout<<"type"<<dek[i].type<<"\n";
std::cout<<"-----END------\n";
}
player.shuffle();
for(int i=1;i<53;i++)
{
std::cout<<"-----CARD-----\n";
std::cout<<"face"<<dek[i].face<<"\n";
std::cout<<"type"<<dek[i].rank<<"\n";
std::cout<<"-----END------\n";
}
return 0;
}