mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2025-12-12 12:22:12 +00:00
convert tabs to spaces
This commit is contained in:
parent
690a14e482
commit
91630a3a34
@ -1,63 +1,63 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
const std::string tennis_score(int p1Score, int p2Score) {
|
const std::string tennis_score(int p1Score, int p2Score) {
|
||||||
std::string score = "";
|
std::string score = "";
|
||||||
int tempScore=0;
|
int tempScore=0;
|
||||||
if (p1Score==p2Score)
|
if (p1Score==p2Score)
|
||||||
{
|
{
|
||||||
switch (p1Score)
|
switch (p1Score)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
score = "Love-All";
|
score = "Love-All";
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
score = "Fifteen-All";
|
score = "Fifteen-All";
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
score = "Thirty-All";
|
score = "Thirty-All";
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
score = "Deuce";
|
score = "Deuce";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
score = "Deuce";
|
score = "Deuce";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (p1Score>=4 || p2Score>=4)
|
else if (p1Score>=4 || p2Score>=4)
|
||||||
{
|
{
|
||||||
int minusResult = p1Score-p2Score;
|
int minusResult = p1Score-p2Score;
|
||||||
if (minusResult==1) score ="Advantage player1";
|
if (minusResult==1) score ="Advantage player1";
|
||||||
else if (minusResult ==-1) score ="Advantage player2";
|
else if (minusResult ==-1) score ="Advantage player2";
|
||||||
else if (minusResult>=2) score = "Win for player1";
|
else if (minusResult>=2) score = "Win for player1";
|
||||||
else score ="Win for player2";
|
else score ="Win for player2";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (int i=1; i<3; i++)
|
for (int i=1; i<3; i++)
|
||||||
{
|
{
|
||||||
if (i==1) tempScore = p1Score;
|
if (i==1) tempScore = p1Score;
|
||||||
else { score+="-"; tempScore = p2Score;}
|
else { score+="-"; tempScore = p2Score;}
|
||||||
switch(tempScore)
|
switch(tempScore)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
score+="Love";
|
score+="Love";
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
score+="Fifteen";
|
score+="Fifteen";
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
score+="Thirty";
|
score+="Thirty";
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
score+="Forty";
|
score+="Forty";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return score;
|
return score;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(TennisTest, LoveAll_0_0) {
|
TEST(TennisTest, LoveAll_0_0) {
|
||||||
|
|||||||
@ -1,94 +1,94 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
const std::string tennis_score(int p1Score, int p2Score) {
|
const std::string tennis_score(int p1Score, int p2Score) {
|
||||||
std::string score = "";
|
std::string score = "";
|
||||||
std::string P1res = "";
|
std::string P1res = "";
|
||||||
std::string P2res = "";
|
std::string P2res = "";
|
||||||
if (p1Score == p2Score && p1Score < 4)
|
if (p1Score == p2Score && p1Score < 4)
|
||||||
{
|
{
|
||||||
if (p1Score==0)
|
if (p1Score==0)
|
||||||
score = "Love";
|
score = "Love";
|
||||||
if (p1Score==1)
|
if (p1Score==1)
|
||||||
score = "Fifteen";
|
score = "Fifteen";
|
||||||
if (p1Score==2)
|
if (p1Score==2)
|
||||||
score = "Thirty";
|
score = "Thirty";
|
||||||
if (p1Score==3)
|
if (p1Score==3)
|
||||||
score = "Forty";
|
score = "Forty";
|
||||||
score += "-All";
|
score += "-All";
|
||||||
}
|
}
|
||||||
if (p1Score==p2Score && p1Score>2)
|
if (p1Score==p2Score && p1Score>2)
|
||||||
score = "Deuce";
|
score = "Deuce";
|
||||||
|
|
||||||
if (p1Score > 0 && p2Score==0)
|
if (p1Score > 0 && p2Score==0)
|
||||||
{
|
{
|
||||||
if (p1Score==1)
|
if (p1Score==1)
|
||||||
P1res = "Fifteen";
|
P1res = "Fifteen";
|
||||||
if (p1Score==2)
|
if (p1Score==2)
|
||||||
P1res = "Thirty";
|
P1res = "Thirty";
|
||||||
if (p1Score==3)
|
if (p1Score==3)
|
||||||
P1res = "Forty";
|
P1res = "Forty";
|
||||||
|
|
||||||
P2res = "Love";
|
P2res = "Love";
|
||||||
score = P1res + "-" + P2res;
|
score = P1res + "-" + P2res;
|
||||||
}
|
}
|
||||||
if (p2Score > 0 && p1Score==0)
|
if (p2Score > 0 && p1Score==0)
|
||||||
{
|
{
|
||||||
if (p2Score==1)
|
if (p2Score==1)
|
||||||
P2res = "Fifteen";
|
P2res = "Fifteen";
|
||||||
if (p2Score==2)
|
if (p2Score==2)
|
||||||
P2res = "Thirty";
|
P2res = "Thirty";
|
||||||
if (p2Score==3)
|
if (p2Score==3)
|
||||||
P2res = "Forty";
|
P2res = "Forty";
|
||||||
|
|
||||||
P1res = "Love";
|
P1res = "Love";
|
||||||
score = P1res + "-" + P2res;
|
score = P1res + "-" + P2res;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p1Score>p2Score && p1Score < 4)
|
if (p1Score>p2Score && p1Score < 4)
|
||||||
{
|
{
|
||||||
if (p1Score==2)
|
if (p1Score==2)
|
||||||
P1res="Thirty";
|
P1res="Thirty";
|
||||||
if (p1Score==3)
|
if (p1Score==3)
|
||||||
P1res="Forty";
|
P1res="Forty";
|
||||||
if (p2Score==1)
|
if (p2Score==1)
|
||||||
P2res="Fifteen";
|
P2res="Fifteen";
|
||||||
if (p2Score==2)
|
if (p2Score==2)
|
||||||
P2res="Thirty";
|
P2res="Thirty";
|
||||||
score = P1res + "-" + P2res;
|
score = P1res + "-" + P2res;
|
||||||
}
|
}
|
||||||
if (p2Score>p1Score && p2Score < 4)
|
if (p2Score>p1Score && p2Score < 4)
|
||||||
{
|
{
|
||||||
if (p2Score==2)
|
if (p2Score==2)
|
||||||
P2res="Thirty";
|
P2res="Thirty";
|
||||||
if (p2Score==3)
|
if (p2Score==3)
|
||||||
P2res="Forty";
|
P2res="Forty";
|
||||||
if (p1Score==1)
|
if (p1Score==1)
|
||||||
P1res="Fifteen";
|
P1res="Fifteen";
|
||||||
if (p1Score==2)
|
if (p1Score==2)
|
||||||
P1res="Thirty";
|
P1res="Thirty";
|
||||||
score = P1res + "-" + P2res;
|
score = P1res + "-" + P2res;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p1Score > p2Score && p2Score >= 3)
|
if (p1Score > p2Score && p2Score >= 3)
|
||||||
{
|
{
|
||||||
score = "Advantage player1";
|
score = "Advantage player1";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p2Score > p1Score && p1Score >= 3)
|
if (p2Score > p1Score && p1Score >= 3)
|
||||||
{
|
{
|
||||||
score = "Advantage player2";
|
score = "Advantage player2";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p1Score>=4 && p2Score>=0 && (p1Score-p2Score)>=2)
|
if (p1Score>=4 && p2Score>=0 && (p1Score-p2Score)>=2)
|
||||||
{
|
{
|
||||||
score = "Win for player1";
|
score = "Win for player1";
|
||||||
}
|
}
|
||||||
if (p2Score>=4 && p1Score>=0 && (p2Score-p1Score)>=2)
|
if (p2Score>=4 && p1Score>=0 && (p2Score-p1Score)>=2)
|
||||||
{
|
{
|
||||||
score = "Win for player2";
|
score = "Win for player2";
|
||||||
}
|
}
|
||||||
return score;
|
return score;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(TennisTest, LoveAll_0_0) {
|
TEST(TennisTest, LoveAll_0_0) {
|
||||||
|
|||||||
@ -1,19 +1,19 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
const std::string tennis_score(int p1, int p2) {
|
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 && !(p1 == 3 && p2 == 3)) {
|
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];
|
||||||
} else {
|
} else {
|
||||||
if (p1 == p2)
|
if (p1 == p2)
|
||||||
return "Deuce";
|
return "Deuce";
|
||||||
s = p1 > p2 ? p1N : p2N;
|
s = p1 > p2 ? p1N : p2N;
|
||||||
return ((p1-p2)*(p1-p2) == 1) ? "Advantage " + s : "Win for " + s;
|
return ((p1-p2)*(p1-p2) == 1) ? "Advantage " + s : "Win for " + s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(TennisTest, LoveAll_0_0) {
|
TEST(TennisTest, LoveAll_0_0) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user