Esempio n. 1
0
        public string GenerateWinner()
        {
            List <Game> nominees = GenerateData.GetGames();

            int     finalVote = 0;
            ILogger logger    = new ConsoleLogger();

            while (nominees.Count != 1)
            {
                for (int i = 0; i < nominees.Count; i++)
                {
                    Random rand = new Random();

                    int a = rand.Next(1, 100000);
                    int b = rand.Next(1, 100000);

                    if (a >= b)
                    {
                        logger.Info($"In a battle between {nominees[i]} and {nominees[i + 1]} the winner is :{nominees[i]} with {a} votes!");
                        nominees.RemoveAt(i + 1);
                    }
                    else
                    {
                        logger.Info($"In a battle between {nominees[i]} and {nominees[i + 1]} the winner is :{nominees[i + 1]} with {b} votes!");
                        nominees.RemoveAt(i);
                    }

                    if (nominees.Count == 1)
                    {
                        if (a > b)
                        {
                            finalVote = a;
                        }
                        else
                        {
                            finalVote = b;
                        }
                    }
                }
            }
            logger.Winner($"The GOTY is {nominees[0]} with {finalVote} votes in the final!");
            string winner = nominees[0].title;

            return(winner);
        }
Esempio n. 2
0
 static void Main(string[] args)
 {
     GenerateData.GetGames();
     GenerateHistoricalDataSet(args);
        public HistoricalDataPoint()
        {
            GenerateData generateData = new GenerateData();

            Winner = generateData.GenerateWinner();
        }