fork download
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace Balloons_Pops_Game_Variant_Four
  5. {
  6. public class ScoreboardInitialization
  7. {
  8. private static List<Player> playersScoreboard;
  9. private static int bestPlayerScore = 0;
  10. private static int worstPlayerScore = int.MaxValue;
  11.  
  12. static ScoreboardInitialization()
  13. {
  14. playersScoreboard = new List<Player>();
  15. }
  16.  
  17. public static void Plot()
  18. {
  19. if (playersScoreboard.Count == 0)
  20. {
  21. ConfigurateEmptyLinesOfMessages.WriteWithEmptyLine(GameMessages.emptyScoreboard);
  22. return;
  23. }
  24. ConfigurateEmptyLinesOfMessages.WriteEmptyLine(); Console.WriteLine();
  25. ConfigurateEmptyLinesOfMessages.WriteWithEmptyLine(GameMessages.scoreboardMessage);
  26.  
  27. List<KeyValuePair<String, Int32>> scoreboardList = Sort();
  28.  
  29. int index = 1;
  30. foreach (KeyValuePair<String, Int32> item in scoreboardList)
  31. {
  32. Console.WriteLine(" {0} {1} --> {2} moves ", index, item.Key, item.Value);
  33. index++;
  34. }
  35. Console.WriteLine();
  36. }
  37.  
  38. private static List<KeyValuePair<String, Int32>> Sort()
  39. {
  40. List<KeyValuePair<String, Int32>> scoreboardList = new List<KeyValuePair<String,Int32>>();
  41. foreach (Player p in playersScoreboard)
  42. {
  43. KeyValuePair<String, Int32> item = new KeyValuePair<string,int>(p.Name, p.Score);
  44. scoreboardList.Add(item);
  45. }
  46.  
  47. scoreboardList.Sort(delegate(KeyValuePair<String, Int32> x,
  48. KeyValuePair<String, Int32> y) { return x.Value.CompareTo(y.Value); });
  49.  
  50. return scoreboardList;
  51. }
  52.  
  53. public static bool ShouldBeRefreshed(Player player)
  54. {
  55. return player.Score <= worstPlayerScore;
  56. }
  57.  
  58. public static void Refresh(Player player)
  59. {
  60. if (!ShouldBeRefreshed(player))
  61. return;
  62. if (playersScoreboard.Count == 5)
  63. DeleteTheWorstPlayer();
  64.  
  65. playersScoreboard.Add(player);
  66. RefreshScores(player);
  67. }
  68.  
  69. private static void DeleteTheWorstPlayer()
  70. {
  71. Player player = new Player();
  72. player.Score = worstPlayerScore;
  73.  
  74. foreach (Player players in playersScoreboard)
  75. {
  76. if(players.Score == worstPlayerScore)
  77. {
  78. player.Name = players.Name;
  79. break;
  80. }
  81. }
  82. playersScoreboard.Remove(player);
  83. }
  84.  
  85. private static void RefreshScores(Player player)
  86. {
  87. if (player.Score < bestPlayerScore)
  88. bestPlayerScore = player.Score;
  89.  
  90. if (playersScoreboard.Count < 5)
  91. worstPlayerScore = int.MaxValue;
  92. else
  93. worstPlayerScore = player.Score;
  94. foreach (Player p in playersScoreboard)
  95. {
  96. if (p.Score > worstPlayerScore)
  97. worstPlayerScore = p.Score;
  98. }
  99. }
  100. }
  101. }
  102.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(8,29): error CS0246: The type or namespace name `Player' could not be found. Are you missing a using directive or an assembly reference?
prog.cs(53,46): error CS0246: The type or namespace name `Player' could not be found. Are you missing a using directive or an assembly reference?
prog.cs(58,36): error CS0246: The type or namespace name `Player' could not be found. Are you missing a using directive or an assembly reference?
prog.cs(85,43): error CS0246: The type or namespace name `Player' could not be found. Are you missing a using directive or an assembly reference?
Compilation failed: 4 error(s), 0 warnings
stdout
Standard output is empty