Exemplo n.º 1
0
        public static void GetRandomTicketWithTwoMatches(SecondSession secondSession)
        {
            foreach (var ticket in Tickets)
            {
                var matches = LottaryHelpers.CheckTicket(secondSession.WinningCombination, ticket.Combination);

                if (matches == 2)
                {
                    Array.Resize(ref TicketsWithTwoMatchings, TicketsWithTwoMatchings.Length + 1);
                    TicketsWithTwoMatchings[^ 1] = ticket;
Exemplo n.º 2
0
        public static void GetRandomTicketWithTwoMatches(SecondSession secondSession)
        {
            foreach (var ticket in Session.Tickets)
            {
                var matches = LottaryHelpers.CheckTicket(secondSession.WinningCombination, ticket.Combination);
                if (matches == 2)
                {
                    Array.Resize(ref Session.TicketsWithTwoMatchings, TicketsWithTwoMatchings.Length + 1);
                    Session.TicketsWithTwoMatchings[TicketsWithTwoMatchings.Length - 1] = ticket;

                    if (TicketsWithTwoMatchings.Length != 0)
                    {
                        var luckyLoserIndex = new Random().Next(0, TicketsWithTwoMatchings.Length - 1);
                        luckyLoserSession = TicketsWithTwoMatchings[luckyLoserIndex];
                        Console.WriteLine($"The lucky loser in second session  is: {luckyLoserSession.User.FullName} and won a Vacation!");
                    }
                }
            }
        }