Browse Source

refactoring: Die Variable an die Konvention angepasst

main
fdai7103 2 years ago
parent
commit
e5242987ae
  1. 14
      src/Paper-Bin.c

14
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);

Loading…
Cancel
Save