forked from Davidlee0314/ProgrammingDesign--majanGame
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMajan.cpp
104 lines (98 loc) · 2.44 KB
/
Majan.cpp
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
//
// Created by User on 2018/12/19.
//
#include "Majan.h"
#include <iostream>
using namespace std;
bool Majan::operator==(Majan a) {
return this->type == a.type && this->num == a.num;
}
bool Majan::operator>=(Majan a) {
return this->type == a.type && this->num == a.num + 1;
}
bool Majan::operator<=(Majan a) {
return this->type == a.type && this->num == a.num - 1;
}
void Majan::print(){
switch (this->type){
case 1:
switch (this->num){
case 1:
cout << "春 ";
break;
case 2:
cout << "夏 ";
break;
case 3:
cout << "秋 ";
break;
case 4:
cout << "冬 ";
break;
case 5:
cout << "梅 ";
break;
case 6:
cout << "蘭 ";
break;
case 7:
cout << "竹 ";
break;
case 8:
cout << "菊 ";
break;
default:
break;
}
break;
case 2:
switch (this->num){
case 1:
cout << "東 ";
break;
case 2:
cout << "南 ";
break;
case 3:
cout << "西 ";
break;
case 4:
cout << "北 ";
break;
case 5:
cout << "中 ";
break;
case 6:
cout << "發 ";
break;
case 7:
cout << "白 ";
break;
default:
break;
}
break;
case 3:
cout << this->num << " 萬 ";
break;
case 4:
cout << this->num << " 筒 ";
break;
case 5:
cout << this->num << " 條 ";
break;
default:
break;
}
}
bool Majan::compare(Majan* a){
bool right = true;
if(type > a->type){
right = false;
}else if(type == a->type){
if(num > a->num){
right = false;
}
}
return right;
}