Ejemplo n.º 1
0
        // Iterates through Winners List.  Counts the times a name is in the winners array and displays
        // the points of the players.
        private void WinnersInBattle()
        {
            Console.WriteLine("\nPlayer Points (1 each for a draw, 1 for the winner)\n");
            var result = Winners
                         .GroupBy(winnername => winnername)
                         .OrderByDescending(winnergroup => winnergroup.Count())
                         .ToList();

            result.ForEach(winnergroup => Console.WriteLine("{0} has {1} points.", winnergroup.Key, winnergroup.Count()));


            // In the event of only one player having points (therefore only one name in the winners List)
            // This ensures a message of 0 points for the loser.
            if (result.Count() == 1)
            {
                var message = " has 0 points.";
                Console.WriteLine(
                    PlayerOne.Name == result[0].Key ? PlayerTwo.Name + message : PlayerOne.Name + message
                    );
            }
        }