예제 #1
0
 /// <summary>
 /// adds highscore into list.
 /// if score is not high enough, it will not add.
 /// </summary>
 /// <param name="name">name of the player</param>
 /// <param name="score">score earned by the player</param>
 public void addHighScore(int score)
 {
     //create new score object with score name
     Score newscore = new Score(name, score);
     //Score index;
     //int j;
     if (isHighScoreChecker(newscore) != -1)
     {
         for(int i = 1; i <= isHighScoreChecker(newscore); i++)
         {
             list[i-1] = list[i];
         }
         list[isHighScoreChecker(newscore)] = newscore;
     }
     updateHighScoreInFile();
 }
예제 #2
0
 /// <summary>
 /// Checks if the new Score is a high score
 /// </summary>
 /// <param name="score">score that is to be compared to with all the other score</param>
 /// <returns></returns>
 private int isHighScoreChecker(Score score)
 {
     for(int i = list.Length - 1; i >= 0; i--)
     {
         if(list[i].getScore() < score.getScore())
         {
             return i;
         }
     }
     return -1;
 }