-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStraight.cpp
More file actions
64 lines (59 loc) · 1.42 KB
/
Straight.cpp
File metadata and controls
64 lines (59 loc) · 1.42 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
#include <vector>
#include "Card.h"
#include "Straight.h"
using namespace std;
Straight::Straight(Card &a,Card &b,Card &c,Card &d,Card &e)
{
if(
(((a.getface())==(b.getface()-1)
&&(b.getface()-1)==(c.getface()-2)
&&(c.getface()-2)==(d.getface()-3)
&&(d.getface()-3)==(e.getface()-4))
&&
((a.getface()!=9)&&(b.getface()!=10)&&(c.getface()!=11)&&(d.getface()!=12)&&(e.getface()!=13)))
||
((a.getface()==1)&&(b.getface()==2)&&(c.getface()==3)&&(d.getface()==12)&&(e.getface()==13))
||
((a.getface()==1)&&(b.getface()==2)&&(c.getface()==3)&&(d.getface()==4)&&(e.getface()==13))
)
{
s[0]=&a;
s[1]=&b;
s[2]=&c;
s[3]=&d;
s[4]=&e;
}
else
cout<<"this straight"<<a.toString()<<","<<b.toString()<<","<<c.toString()<<","<<d.toString()<<","<<e.toString()<<"is not a straight!\n";
maxCard=s[4];
minCard=s[0];
}
Straight::Straight()
{
Card a,b,c,d,e;
s[0]=&a;
s[1]=&b;
s[2]=&c;
s[3]=&d;
s[4]=&e;
}
string Straight::toString()
{
return s[0]->toString()+" & "+s[1]->toString()+" & "+s[2]->toString()+" & "+s[3]->toString()+" & "+s[4]->toString();
}
int Straight::CompareStraight(Straight A,Straight B)
{
if((A.maxCard->value)>(B.maxCard->value))
return 1;
else if((A.maxCard->value)<(B.maxCard->value))
return 0;
else
return -1;
}
void Straight::swap(Straight& a,Straight& b)
{
Straight tmp;
tmp=a;
a=b;
b=tmp;
}