mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2025-12-12 12:22:12 +00:00
On closer examination of the rules I notice Forty-All should in fact be Deuce
This commit is contained in:
parent
34b36ec3f2
commit
926f8a2686
@ -17,7 +17,7 @@ const std::string tennis_score(int p1Score, int p2Score) {
|
|||||||
score = "Thirty-All";
|
score = "Thirty-All";
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
score = "Forty-All";
|
score = "Deuce";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
score = "Deuce";
|
score = "Deuce";
|
||||||
@ -75,8 +75,8 @@ TEST(TennisTest, ThirtyAll_2_2) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(TennisTest, FortyAll_3_3) {
|
TEST(TennisTest, Deuce_3_3) {
|
||||||
EXPECT_EQ("Forty-All", tennis_score(3, 3));
|
EXPECT_EQ("Deuce", tennis_score(3, 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,7 @@ const std::string tennis_score(int p1Score, int p2Score) {
|
|||||||
score = "Forty";
|
score = "Forty";
|
||||||
score += "-All";
|
score += "-All";
|
||||||
}
|
}
|
||||||
if (p1Score==p2Score && p1Score>3)
|
if (p1Score==p2Score && p1Score>2)
|
||||||
score = "Deuce";
|
score = "Deuce";
|
||||||
|
|
||||||
if (p1Score > 0 && p2Score==0)
|
if (p1Score > 0 && p2Score==0)
|
||||||
@ -106,8 +106,8 @@ TEST(TennisTest, ThirtyAll_2_2) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(TennisTest, FortyAll_3_3) {
|
TEST(TennisTest, Deuce_3_3) {
|
||||||
EXPECT_EQ("Forty-All", tennis_score(3, 3));
|
EXPECT_EQ("Deuce", tennis_score(3, 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@ const std::string tennis_score(int p1, int p2) {
|
|||||||
std::string s;
|
std::string s;
|
||||||
std::string p1N = "player1";
|
std::string p1N = "player1";
|
||||||
std::string p2N = "player2";
|
std::string p2N = "player2";
|
||||||
if (p1 < 4 && p2 < 4) {
|
if (p1 < 4 && p2 < 4 && !(p1 == 3 && p2 == 3)) {
|
||||||
std::string p[4] = {"Love", "Fifteen", "Thirty", "Forty"};
|
std::string p[4] = {"Love", "Fifteen", "Thirty", "Forty"};
|
||||||
s = p[p1];
|
s = p[p1];
|
||||||
return (p1 == p2) ? s + "-All" : s + "-" + p[p2];
|
return (p1 == p2) ? s + "-All" : s + "-" + p[p2];
|
||||||
@ -31,8 +31,8 @@ TEST(TennisTest, ThirtyAll_2_2) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(TennisTest, FortyAll_3_3) {
|
TEST(TennisTest, Deuce_3_3) {
|
||||||
EXPECT_EQ("Forty-All", tennis_score(3, 3));
|
EXPECT_EQ("Deuce", tennis_score(3, 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,7 @@ TEST(TennisTest, %(testcase_name)s) {
|
|||||||
test_cases = [dict(p1Points=0, p2Points=0, score="Love-All"),
|
test_cases = [dict(p1Points=0, p2Points=0, score="Love-All"),
|
||||||
dict(p1Points=1, p2Points=1, score="Fifteen-All"),
|
dict(p1Points=1, p2Points=1, score="Fifteen-All"),
|
||||||
dict(p1Points=2, p2Points=2, score="Thirty-All"),
|
dict(p1Points=2, p2Points=2, score="Thirty-All"),
|
||||||
dict(p1Points=3, p2Points=3, score="Forty-All"),
|
dict(p1Points=3, p2Points=3, score="Deuce"),
|
||||||
dict(p1Points=4, p2Points=4, score="Deuce"),
|
dict(p1Points=4, p2Points=4, score="Deuce"),
|
||||||
|
|
||||||
dict(p1Points=1, p2Points=0, score="Fifteen-Love"),
|
dict(p1Points=1, p2Points=0, score="Fifteen-Love"),
|
||||||
|
|||||||
@ -19,8 +19,8 @@ TEST(TennisTest, ThirtyAll_2_2) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(TennisTest, FortyAll_3_3) {
|
TEST(TennisTest, Deuce_3_3) {
|
||||||
EXPECT_EQ("Forty-All", tennis_score(3, 3));
|
EXPECT_EQ("Deuce", tennis_score(3, 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user