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,62 +1,62 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
const std::string tennis_score(int p1Score, int p2Score) {
|
||||
std::string score = "";
|
||||
int tempScore=0;
|
||||
if (p1Score==p2Score)
|
||||
{
|
||||
switch (p1Score)
|
||||
{
|
||||
case 0:
|
||||
score = "Love-All";
|
||||
break;
|
||||
case 1:
|
||||
score = "Fifteen-All";
|
||||
break;
|
||||
case 2:
|
||||
score = "Thirty-All";
|
||||
break;
|
||||
case 3:
|
||||
score = "Deuce";
|
||||
break;
|
||||
default:
|
||||
score = "Deuce";
|
||||
break;
|
||||
std::string score = "";
|
||||
int tempScore=0;
|
||||
if (p1Score==p2Score)
|
||||
{
|
||||
switch (p1Score)
|
||||
{
|
||||
case 0:
|
||||
score = "Love-All";
|
||||
break;
|
||||
case 1:
|
||||
score = "Fifteen-All";
|
||||
break;
|
||||
case 2:
|
||||
score = "Thirty-All";
|
||||
break;
|
||||
case 3:
|
||||
score = "Deuce";
|
||||
break;
|
||||
default:
|
||||
score = "Deuce";
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
else if (p1Score>=4 || p2Score>=4)
|
||||
{
|
||||
int minusResult = p1Score-p2Score;
|
||||
if (minusResult==1) score ="Advantage player1";
|
||||
else if (minusResult ==-1) score ="Advantage player2";
|
||||
else if (minusResult>=2) score = "Win for player1";
|
||||
else score ="Win for player2";
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i=1; i<3; i++)
|
||||
{
|
||||
if (i==1) tempScore = p1Score;
|
||||
else { score+="-"; tempScore = p2Score;}
|
||||
switch(tempScore)
|
||||
{
|
||||
case 0:
|
||||
score+="Love";
|
||||
break;
|
||||
case 1:
|
||||
score+="Fifteen";
|
||||
break;
|
||||
case 2:
|
||||
score+="Thirty";
|
||||
break;
|
||||
case 3:
|
||||
score+="Forty";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return score;
|
||||
}
|
||||
}
|
||||
else if (p1Score>=4 || p2Score>=4)
|
||||
{
|
||||
int minusResult = p1Score-p2Score;
|
||||
if (minusResult==1) score ="Advantage player1";
|
||||
else if (minusResult ==-1) score ="Advantage player2";
|
||||
else if (minusResult>=2) score = "Win for player1";
|
||||
else score ="Win for player2";
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i=1; i<3; i++)
|
||||
{
|
||||
if (i==1) tempScore = p1Score;
|
||||
else { score+="-"; tempScore = p2Score;}
|
||||
switch(tempScore)
|
||||
{
|
||||
case 0:
|
||||
score+="Love";
|
||||
break;
|
||||
case 1:
|
||||
score+="Fifteen";
|
||||
break;
|
||||
case 2:
|
||||
score+="Thirty";
|
||||
break;
|
||||
case 3:
|
||||
score+="Forty";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return score;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1,93 +1,93 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
const std::string tennis_score(int p1Score, int p2Score) {
|
||||
std::string score = "";
|
||||
std::string score = "";
|
||||
std::string P1res = "";
|
||||
std::string P2res = "";
|
||||
if (p1Score == p2Score && p1Score < 4)
|
||||
{
|
||||
if (p1Score==0)
|
||||
score = "Love";
|
||||
if (p1Score==1)
|
||||
score = "Fifteen";
|
||||
if (p1Score==2)
|
||||
score = "Thirty";
|
||||
if (p1Score==3)
|
||||
score = "Forty";
|
||||
score += "-All";
|
||||
}
|
||||
if (p1Score==p2Score && p1Score>2)
|
||||
score = "Deuce";
|
||||
if (p1Score == p2Score && p1Score < 4)
|
||||
{
|
||||
if (p1Score==0)
|
||||
score = "Love";
|
||||
if (p1Score==1)
|
||||
score = "Fifteen";
|
||||
if (p1Score==2)
|
||||
score = "Thirty";
|
||||
if (p1Score==3)
|
||||
score = "Forty";
|
||||
score += "-All";
|
||||
}
|
||||
if (p1Score==p2Score && p1Score>2)
|
||||
score = "Deuce";
|
||||
|
||||
if (p1Score > 0 && p2Score==0)
|
||||
{
|
||||
if (p1Score==1)
|
||||
P1res = "Fifteen";
|
||||
if (p1Score==2)
|
||||
P1res = "Thirty";
|
||||
if (p1Score==3)
|
||||
P1res = "Forty";
|
||||
if (p1Score > 0 && p2Score==0)
|
||||
{
|
||||
if (p1Score==1)
|
||||
P1res = "Fifteen";
|
||||
if (p1Score==2)
|
||||
P1res = "Thirty";
|
||||
if (p1Score==3)
|
||||
P1res = "Forty";
|
||||
|
||||
P2res = "Love";
|
||||
score = P1res + "-" + P2res;
|
||||
}
|
||||
if (p2Score > 0 && p1Score==0)
|
||||
{
|
||||
if (p2Score==1)
|
||||
P2res = "Fifteen";
|
||||
if (p2Score==2)
|
||||
P2res = "Thirty";
|
||||
if (p2Score==3)
|
||||
P2res = "Forty";
|
||||
P2res = "Love";
|
||||
score = P1res + "-" + P2res;
|
||||
}
|
||||
if (p2Score > 0 && p1Score==0)
|
||||
{
|
||||
if (p2Score==1)
|
||||
P2res = "Fifteen";
|
||||
if (p2Score==2)
|
||||
P2res = "Thirty";
|
||||
if (p2Score==3)
|
||||
P2res = "Forty";
|
||||
|
||||
P1res = "Love";
|
||||
score = P1res + "-" + P2res;
|
||||
}
|
||||
P1res = "Love";
|
||||
score = P1res + "-" + P2res;
|
||||
}
|
||||
|
||||
if (p1Score>p2Score && p1Score < 4)
|
||||
{
|
||||
if (p1Score==2)
|
||||
P1res="Thirty";
|
||||
if (p1Score==3)
|
||||
P1res="Forty";
|
||||
if (p2Score==1)
|
||||
P2res="Fifteen";
|
||||
if (p2Score==2)
|
||||
P2res="Thirty";
|
||||
score = P1res + "-" + P2res;
|
||||
}
|
||||
if (p2Score>p1Score && p2Score < 4)
|
||||
{
|
||||
if (p2Score==2)
|
||||
P2res="Thirty";
|
||||
if (p2Score==3)
|
||||
P2res="Forty";
|
||||
if (p1Score==1)
|
||||
P1res="Fifteen";
|
||||
if (p1Score==2)
|
||||
P1res="Thirty";
|
||||
score = P1res + "-" + P2res;
|
||||
}
|
||||
if (p1Score>p2Score && p1Score < 4)
|
||||
{
|
||||
if (p1Score==2)
|
||||
P1res="Thirty";
|
||||
if (p1Score==3)
|
||||
P1res="Forty";
|
||||
if (p2Score==1)
|
||||
P2res="Fifteen";
|
||||
if (p2Score==2)
|
||||
P2res="Thirty";
|
||||
score = P1res + "-" + P2res;
|
||||
}
|
||||
if (p2Score>p1Score && p2Score < 4)
|
||||
{
|
||||
if (p2Score==2)
|
||||
P2res="Thirty";
|
||||
if (p2Score==3)
|
||||
P2res="Forty";
|
||||
if (p1Score==1)
|
||||
P1res="Fifteen";
|
||||
if (p1Score==2)
|
||||
P1res="Thirty";
|
||||
score = P1res + "-" + P2res;
|
||||
}
|
||||
|
||||
if (p1Score > p2Score && p2Score >= 3)
|
||||
{
|
||||
score = "Advantage player1";
|
||||
}
|
||||
if (p1Score > p2Score && p2Score >= 3)
|
||||
{
|
||||
score = "Advantage player1";
|
||||
}
|
||||
|
||||
if (p2Score > p1Score && p1Score >= 3)
|
||||
{
|
||||
score = "Advantage player2";
|
||||
}
|
||||
if (p2Score > p1Score && p1Score >= 3)
|
||||
{
|
||||
score = "Advantage player2";
|
||||
}
|
||||
|
||||
if (p1Score>=4 && p2Score>=0 && (p1Score-p2Score)>=2)
|
||||
{
|
||||
score = "Win for player1";
|
||||
}
|
||||
if (p2Score>=4 && p1Score>=0 && (p2Score-p1Score)>=2)
|
||||
{
|
||||
score = "Win for player2";
|
||||
}
|
||||
return score;
|
||||
if (p1Score>=4 && p2Score>=0 && (p1Score-p2Score)>=2)
|
||||
{
|
||||
score = "Win for player1";
|
||||
}
|
||||
if (p2Score>=4 && p1Score>=0 && (p2Score-p1Score)>=2)
|
||||
{
|
||||
score = "Win for player2";
|
||||
}
|
||||
return score;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1,19 +1,19 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
const std::string tennis_score(int p1, int p2) {
|
||||
std::string s;
|
||||
std::string s;
|
||||
std::string p1N = "player1";
|
||||
std::string p2N = "player2";
|
||||
if (p1 < 4 && p2 < 4 && !(p1 == 3 && p2 == 3)) {
|
||||
std::string p[4] = {"Love", "Fifteen", "Thirty", "Forty"};
|
||||
s = p[p1];
|
||||
return (p1 == p2) ? s + "-All" : s + "-" + p[p2];
|
||||
} else {
|
||||
if (p1 == p2)
|
||||
return "Deuce";
|
||||
s = p1 > p2 ? p1N : p2N;
|
||||
return ((p1-p2)*(p1-p2) == 1) ? "Advantage " + s : "Win for " + s;
|
||||
}
|
||||
if (p1 < 4 && p2 < 4 && !(p1 == 3 && p2 == 3)) {
|
||||
std::string p[4] = {"Love", "Fifteen", "Thirty", "Forty"};
|
||||
s = p[p1];
|
||||
return (p1 == p2) ? s + "-All" : s + "-" + p[p2];
|
||||
} else {
|
||||
if (p1 == p2)
|
||||
return "Deuce";
|
||||
s = p1 > p2 ? p1N : p2N;
|
||||
return ((p1-p2)*(p1-p2) == 1) ? "Advantage " + s : "Win for " + s;
|
||||
}
|
||||
}
|
||||
|
||||
TEST(TennisTest, LoveAll_0_0) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user