예제 #1
0
        static void DisplayHighScores()
        {
            Console.Clear();
            Console.WriteLine("HangMan");
            Console.WriteLine("-------");
            OwenEntities     db             = new OwenEntities();
            List <HighScore> highScoresList = db.HighScores.Where(x => x.Game == "HangMan").OrderByDescending(x => x.Score).Take(10).ToList();

            foreach (HighScore highScore in highScoresList)
            {
                Console.WriteLine("{0}, {1} - {2} on {3}", highScoresList.IndexOf(highScore) + 1, highScore.Name, highScore.Score);
            }
        }
예제 #2
0
        static void AddHighScore(int playerScore)
        {
            Console.WriteLine("Your Name");
            string       playerName   = Console.ReadLine();
            OwenEntities db           = new OwenEntities();
            HighScore    newHighScore = new HighScore();

            newHighScore.DateCreated = DateTime.Now;
            newHighScore.Game        = "HangMan";
            newHighScore.Name        = playerName;
            newHighScore.Score       = playerScore;

            db.HighScores.Add(newHighScore);
            db.SaveChanges();
        }