コード例 #1
0
        /// <summary>
        /// Function that renders the highscore table in the console
        /// </summary>
        /// <param name="highscore">"Highscore table"</param>
        public static void ShowHighscoreTable(HighscoreTable highscore)
        {
            Console.WriteLine("Ψѧ-----|");

            // Checks every possible spot of the table.
            for (int i = 0; i < 10; i++)
            {
                // Gets the score correspondent to the spot.
                Score score = highscore.GetScore(i);

                // If theres a score in the expecifict spot, print it.
                if (score != null)
                {
                    Console.WriteLine($"| Name: {score.Name} " +
                                      $"+Ѡ+ Score: {score.NewScore}");
                }
            }

            Console.WriteLine("Ψѧ-----|\n");

            Console.WriteLine("Ψѧ-------------------------------------ѧΨ");
            Console.WriteLine("| Press 'ENTER', or any key, to return. |");
            Console.WriteLine("Ψѧ-------------------------------------ѧΨ");

            WriteOnString(true);
        }
コード例 #2
0
ファイル: SaveManager.cs プロジェクト: condmaker/lp1_proj3
        /// <summary>
        /// Saves the data of the Highscore Table in a file
        /// </summary>
        /// <param name="highscore">Highscore table to be saved</param>
        public static void Save(HighscoreTable highscore)
        {
            // Open file in writeable mode
            StreamWriter sw = new StreamWriter("scores.txt");

            // Checks every possible spot of the table.
            for (int i = 0; i < 10; i++)
            {
                // Gets the score correspondent to the spot.
                Score score = highscore.GetScore(i);

                // If theres a score in the specific spot, print it.
                if (score != null)
                {
                    sw.WriteLine(score.Name + " " + score.NewScore);
                }
            }

            // Close file
            sw.Close();
        }