mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-10-15 10:33:53 +00:00
converted tabs to spaces
This commit is contained in:
1 parent
afc37306a8
commit
8e3bd6076f
4 files changed
+300
-300
No files matched your search
@@ -2,137 +2,137 @@ package defactored2;
|
||||
|
||||
public class TennisGame
|
||||
{
|
||||
public int P1point = 0;
|
||||
public int P2point = 0;
|
||||
|
||||
public String P1res = "";
|
||||
public String P2res = "";
|
||||
private String player1Name;
|
||||
private String player2Name;
|
||||
public int P1point = 0;
|
||||
public int P2point = 0;
|
||||
|
||||
public String P1res = "";
|
||||
public String P2res = "";
|
||||
private String player1Name;
|
||||
private String player2Name;
|
||||
|
||||
public TennisGame(String player1Name, String player2Name) {
|
||||
this.player1Name = player1Name;
|
||||
this.player2Name = player2Name;
|
||||
}
|
||||
public TennisGame(String player1Name, String player2Name) {
|
||||
this.player1Name = player1Name;
|
||||
this.player2Name = player2Name;
|
||||
}
|
||||
|
||||
public String getScore(){
|
||||
String score = "";
|
||||
if (P1point == P2point && P1point < 4)
|
||||
{
|
||||
if (P1point==0)
|
||||
score = "Love";
|
||||
if (P1point==1)
|
||||
score = "Fifteen";
|
||||
if (P1point==2)
|
||||
score = "Thirty";
|
||||
if (P1point==3)
|
||||
score = "Forty";
|
||||
score += "-All";
|
||||
}
|
||||
if (P1point==P2point && P1point>3)
|
||||
score = "Deuce";
|
||||
|
||||
if (P1point > 0 && P2point==0)
|
||||
{
|
||||
if (P1point==1)
|
||||
P1res = "Fifteen";
|
||||
if (P1point==2)
|
||||
P1res = "Thirty";
|
||||
if (P1point==3)
|
||||
P1res = "Forty";
|
||||
|
||||
P2res = "Love";
|
||||
score = P1res + "-" + P2res;
|
||||
}
|
||||
if (P2point > 0 && P1point==0)
|
||||
{
|
||||
if (P2point==1)
|
||||
P2res = "Fifteen";
|
||||
if (P2point==2)
|
||||
P2res = "Thirty";
|
||||
if (P2point==3)
|
||||
P2res = "Forty";
|
||||
|
||||
P1res = "Love";
|
||||
score = P1res + "-" + P2res;
|
||||
}
|
||||
|
||||
if (P1point>P2point && P1point < 4)
|
||||
{
|
||||
if (P1point==2)
|
||||
P1res="Thirty";
|
||||
if (P1point==3)
|
||||
P1res="Forty";
|
||||
if (P2point==1)
|
||||
P2res="Fifteen";
|
||||
if (P2point==2)
|
||||
P2res="Thirty";
|
||||
score = P1res + "-" + P2res;
|
||||
}
|
||||
if (P2point>P1point && P2point < 4)
|
||||
{
|
||||
if (P2point==2)
|
||||
P2res="Thirty";
|
||||
if (P2point==3)
|
||||
P2res="Forty";
|
||||
if (P1point==1)
|
||||
P1res="Fifteen";
|
||||
if (P1point==2)
|
||||
P1res="Thirty";
|
||||
score = P1res + "-" + P2res;
|
||||
}
|
||||
|
||||
if (P1point > P2point && P2point >= 3)
|
||||
{
|
||||
score = "Advantage player1";
|
||||
}
|
||||
|
||||
if (P2point > P1point && P1point >= 3)
|
||||
{
|
||||
score = "Advantage player2";
|
||||
}
|
||||
|
||||
if (P1point>=4 && P2point>=0 && (P1point-P2point)>=2)
|
||||
{
|
||||
score = "Win for player1";
|
||||
}
|
||||
if (P2point>=4 && P1point>=0 && (P2point-P1point)>=2)
|
||||
{
|
||||
score = "Win for player2";
|
||||
}
|
||||
return score;
|
||||
}
|
||||
|
||||
public void SetP1Score(int number){
|
||||
String score = "";
|
||||
if (P1point == P2point && P1point < 4)
|
||||
{
|
||||
if (P1point==0)
|
||||
score = "Love";
|
||||
if (P1point==1)
|
||||
score = "Fifteen";
|
||||
if (P1point==2)
|
||||
score = "Thirty";
|
||||
if (P1point==3)
|
||||
score = "Forty";
|
||||
score += "-All";
|
||||
}
|
||||
if (P1point==P2point && P1point>3)
|
||||
score = "Deuce";
|
||||
|
||||
for (int i = 0; i < number; i++)
|
||||
{
|
||||
P1Score();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void SetP2Score(int number){
|
||||
if (P1point > 0 && P2point==0)
|
||||
{
|
||||
if (P1point==1)
|
||||
P1res = "Fifteen";
|
||||
if (P1point==2)
|
||||
P1res = "Thirty";
|
||||
if (P1point==3)
|
||||
P1res = "Forty";
|
||||
|
||||
P2res = "Love";
|
||||
score = P1res + "-" + P2res;
|
||||
}
|
||||
if (P2point > 0 && P1point==0)
|
||||
{
|
||||
if (P2point==1)
|
||||
P2res = "Fifteen";
|
||||
if (P2point==2)
|
||||
P2res = "Thirty";
|
||||
if (P2point==3)
|
||||
P2res = "Forty";
|
||||
|
||||
P1res = "Love";
|
||||
score = P1res + "-" + P2res;
|
||||
}
|
||||
|
||||
for (int i = 0; i < number; i++)
|
||||
{
|
||||
P2Score();
|
||||
}
|
||||
|
||||
if (P1point>P2point && P1point < 4)
|
||||
{
|
||||
if (P1point==2)
|
||||
P1res="Thirty";
|
||||
if (P1point==3)
|
||||
P1res="Forty";
|
||||
if (P2point==1)
|
||||
P2res="Fifteen";
|
||||
if (P2point==2)
|
||||
P2res="Thirty";
|
||||
score = P1res + "-" + P2res;
|
||||
}
|
||||
if (P2point>P1point && P2point < 4)
|
||||
{
|
||||
if (P2point==2)
|
||||
P2res="Thirty";
|
||||
if (P2point==3)
|
||||
P2res="Forty";
|
||||
if (P1point==1)
|
||||
P1res="Fifteen";
|
||||
if (P1point==2)
|
||||
P1res="Thirty";
|
||||
score = P1res + "-" + P2res;
|
||||
}
|
||||
|
||||
if (P1point > P2point && P2point >= 3)
|
||||
{
|
||||
score = "Advantage player1";
|
||||
}
|
||||
|
||||
if (P2point > P1point && P1point >= 3)
|
||||
{
|
||||
score = "Advantage player2";
|
||||
}
|
||||
|
||||
if (P1point>=4 && P2point>=0 && (P1point-P2point)>=2)
|
||||
{
|
||||
score = "Win for player1";
|
||||
}
|
||||
if (P2point>=4 && P1point>=0 && (P2point-P1point)>=2)
|
||||
{
|
||||
score = "Win for player2";
|
||||
}
|
||||
return score;
|
||||
}
|
||||
|
||||
public void P1Score(){
|
||||
|
||||
public void SetP1Score(int number){
|
||||
|
||||
for (int i = 0; i < number; i++)
|
||||
{
|
||||
P1Score();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void SetP2Score(int number){
|
||||
|
||||
for (int i = 0; i < number; i++)
|
||||
{
|
||||
P2Score();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void P1Score(){
|
||||
P1point++;
|
||||
}
|
||||
|
||||
public void P2Score(){
|
||||
|
||||
public void P2Score(){
|
||||
P2point++;
|
||||
}
|
||||
|
||||
public void wonPoint(String player) {
|
||||
if (player == "player1")
|
||||
P1Score();
|
||||
else
|
||||
P2Score();
|
||||
}
|
||||
public void wonPoint(String player) {
|
||||
if (player == "player1")
|
||||
P1Score();
|
||||
else
|
||||
P2Score();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user