Difference between revisions of "High score table feature"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
m
Line 5: Line 5:
 
{
 
{
 
     StreamReader UpdateHSTable = new StreamReader("highscores.txt");
 
     StreamReader UpdateHSTable = new StreamReader("highscores.txt");
     string[10] HSTable = System.IO.File.ReadAllLines("highscores.txt");;
+
     string[] HSTable = System.IO.File.ReadAllLines("highscores.txt");
      
+
    string[2] TempTable;
 +
    for (int a = 0; a < 10; a++;)
 +
    {
 +
        if (PlayerOneScore >= Convert.ToInt32(HSTable[a]))
 +
        {
 +
        TempTable[0] = HSTable[a]
 +
        HSTable[a]
 +
        }
 +
       
 +
     }
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>

Revision as of 10:50, 19 February 2018

At the end of the game, take the high score and check the current table of high scores to see if it can go on the table. Then, add in the result and move or remove any other high scores lower in the table or that have fallen off the table. This text file could save every score played from the game, but I'll do top ten to add the removing feature. The scores also need a name attributed to them, so let the user input some letters to save with their score, and then add a way to display the table.

 1 static void HSUpdate()
 2 {
 3     StreamReader UpdateHSTable = new StreamReader("highscores.txt");
 4     string[] HSTable = System.IO.File.ReadAllLines("highscores.txt");
 5     string[2] TempTable;
 6     for (int a = 0; a < 10; a++;)
 7     {
 8         if (PlayerOneScore >= Convert.ToInt32(HSTable[a]))
 9         {
10         TempTable[0] = HSTable[a]
11         HSTable[a]
12         }
13         
14     }
15 }