Skip to content

Commit

Permalink
All tests pass.
Browse files Browse the repository at this point in the history
  • Loading branch information
codecop committed Dec 10, 2023
1 parent 76e848c commit 4f5d77e
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions c/TennisGame4.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void deuce_getResult(struct ResultProvider *this, struct TennisResult *result) {
strcpy(result->serverScore, "Deuce");
}
else
this->functionPtr(this->nextResult, result);
this->nextResult->functionPtr(this->nextResult, result);
}

void gameServer_getResult(struct ResultProvider *this, struct TennisResult *result) {
Expand All @@ -88,7 +88,7 @@ void gameServer_getResult(struct ResultProvider *this, struct TennisResult *resu
strcat(result->serverScore, this->game->server);
}
else
this->functionPtr(this->nextResult, result);
this->nextResult->functionPtr(this->nextResult, result);
}

void gameReceiver_getResult(struct ResultProvider *this, struct TennisResult *result) {
Expand All @@ -98,7 +98,7 @@ void gameReceiver_getResult(struct ResultProvider *this, struct TennisResult *re
strcat(result->serverScore, this->game->receiver);
}
else
this->functionPtr(this->nextResult, result);
this->nextResult->functionPtr(this->nextResult, result);
}

void advantageServer_getResult(struct ResultProvider *this, struct TennisResult *result) {
Expand All @@ -108,7 +108,7 @@ void advantageServer_getResult(struct ResultProvider *this, struct TennisResult
strcat(result->serverScore, this->game->server);
}
else
this->functionPtr(this->nextResult, result);
this->nextResult->functionPtr(this->nextResult, result);
}

void advantageReceiver_getResult(struct ResultProvider *this, struct TennisResult *result) {
Expand All @@ -118,14 +118,13 @@ void advantageReceiver_getResult(struct ResultProvider *this, struct TennisResul
strcat(result->serverScore, this->game->receiver);
}
else
this->functionPtr(this->nextResult, result);
this->nextResult->functionPtr(this->nextResult, result);
}

void defaultResult_getResult(struct ResultProvider *this, struct TennisResult *result) {
// printf("GAME %s, %s, %d, %d\n", this->game->server, this->game->receiver, this->game->serverScore, this->game->receiverScore);
// const char *scores[] = {"Love", "Fifteen", "Thirty", "Forty"};
// strcpy(result->serverScore, scores[this->game->serverScore]);
// strcpy(result->receiverScore, scores[this->game->receiverScore]);
const char *scores[] = {"Love", "Fifteen", "Thirty", "Forty"};
strcpy(result->serverScore, scores[this->game->serverScore]);
strcpy(result->receiverScore, scores[this->game->receiverScore]);
}

const char *TennisGame_GetScore(struct TennisGame *game) {
Expand Down

0 comments on commit 4f5d77e

Please sign in to comment.