From e5242987aefba613bf0012f63edda7f28b7df292 Mon Sep 17 00:00:00 2001 From: fdai7103 Date: Thu, 9 Feb 2023 00:55:43 +0100 Subject: [PATCH] refactoring: Die Variable an die Konvention angepasst --- src/Paper-Bin.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Paper-Bin.c b/src/Paper-Bin.c index 37439c5..172fc3c 100644 --- a/src/Paper-Bin.c +++ b/src/Paper-Bin.c @@ -45,8 +45,8 @@ int checkBallPosition(); //jedem Spieler seinen Score zuweisen zu können struct Player { - char Name[50]; - int Points; + char name[50]; + int points; } playerList[11]; //Methode die den Eimer erstellt @@ -334,12 +334,12 @@ void sortScoreboard() for (int j = 0; fgets(line, sizeof line, file) != NULL && j <= 10; j++) { char* playerTmp = strtok(line, " "); - strcpy(playerList[j].Name, playerTmp); + strcpy(playerList[j].name, playerTmp); playerTmp = strtok(NULL, " "); int playerPoints = atoi(playerTmp); - playerList[j].Points = playerPoints; + playerList[j].points = playerPoints; numberOfLines = j; sleep(0.1); @@ -351,7 +351,7 @@ void sortScoreboard() { for (int j = 0; j < (numberOfLines - i); j++) { - if (playerList[i].Points < playerList[i + 1].Points) + if (playerList[i].points < playerList[i + 1].points) { tmp = playerList[i]; playerList[i] = playerList[i + 1]; @@ -365,14 +365,14 @@ void sortScoreboard() printf(" Scoreboard:\n\n"); for (int j = 0; j < numberOfLines; j++) { - printf("%d. %s %s %d\n", j + 1, (j < 9) ? " " : " ", playerList[j].Name, playerList[j].Points); + printf("%d. %s %s %d\n", j + 1, (j < 9) ? " " : " ", playerList[j].name, playerList[j].points); sleep(0.5); } FILE *fp = fopen("ScoreBoard.txt", "w"); for (int i = 0; i < numberOfLines; i++) { - fprintf(fp, "%s %d\n", playerList[i].Name, playerList[i].Points); + fprintf(fp, "%s %d\n", playerList[i].name, playerList[i].points); } fclose(fp);