回答編集履歴
1
修正
test
CHANGED
@@ -22,9 +22,21 @@
|
|
22
22
|
|
23
23
|
Card (int n=0, Suit s=Suit(-1)) : number(n), suit(s) {}
|
24
24
|
|
25
|
-
int getNumber() const {
|
25
|
+
int getNumber() const {
|
26
26
|
|
27
|
+
if ( number < 1 || number > 13 ) throw std::range_error("bad Number");
|
28
|
+
|
29
|
+
return number;
|
30
|
+
|
31
|
+
}
|
32
|
+
|
27
|
-
Suit getSuit() const {
|
33
|
+
Suit getSuit() const {
|
34
|
+
|
35
|
+
if ( int(suit) < 0 || int(suit) > 3 ) throw std::range_error("bad Suit");
|
36
|
+
|
37
|
+
return suit;
|
38
|
+
|
39
|
+
}
|
28
40
|
|
29
41
|
std::string description() const;
|
30
42
|
|
@@ -46,7 +58,7 @@
|
|
46
58
|
|
47
59
|
}
|
48
60
|
|
49
|
-
t
|
61
|
+
return std::string();
|
50
62
|
|
51
63
|
}
|
52
64
|
|
@@ -60,11 +72,7 @@
|
|
60
72
|
|
61
73
|
"Jack", "Queen", "King" };
|
62
74
|
|
63
|
-
int num = getNumber();
|
64
|
-
|
65
|
-
if ( num < 1 || num > 13 ) throw std::invalid_argument("bad Number");
|
66
|
-
|
67
|
-
return std::string(nums[
|
75
|
+
return std::string(nums[getNumber()-1]) + " " + to_string(getSuit());
|
68
76
|
|
69
77
|
}
|
70
78
|
|