-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPair.cpp
More file actions
54 lines (51 loc) · 1.11 KB
/
Pair.cpp
File metadata and controls
54 lines (51 loc) · 1.11 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
#include <iostream>
#include <string>
#include <vector>
#include "Card.h"
#include "Pair.h"
using namespace std;
Pair::Pair(Card &a,Card &b)
{
if(a.getface()==b.getface())
{
p1=&a;
p2=&b;
}
else
{
cout<<"this pair"<<a.toString()<<","<<b.toString()<<"is not a pair!\n";
}
maxCard=((p1->getsuit())>(p2->getsuit()))?p1:p2;
minCard=((p1->getsuit())>(p2->getsuit()))?p2:p1;
}
//contructor of the class: Pair
//Find the max card and assign it to maxCard
//The constructor when no inputs received
Pair::Pair(){
Card a;
Card b;
p1=&a;
p2=&b;
}
int Pair::ComparePair(Pair A,Pair B){
if((A.maxCard->value)>(B.maxCard->value))
return 1;
else if((A.maxCard->value)<(B.maxCard->value))
return 0;
else
return -1;
}
//compare two "pair.maxCard.value"
//If the former is bigger , return 1 , if latter is bigger , then return 0.
//And if the values are the same , return (error message) -1.
string Pair::toString()
{
return p1->toString()+" & "+p2->toString();
}
void Pair::swap(Pair& a,Pair& b)
{
Pair tmp;
tmp=a;
a=b;
b=tmp;
}