Пример #1
0
        // method to check for every list of draws if there are same numbers with the list of number of eatch player
        public static void DrawChecking(List <Draw> randomDraws, List <Player> player)
        {
            foreach (Draw draw in randomDraws)
            {
                // every time i call this method my fields start over zero value
                AssignZeroAtFields();

                // method to CHECK if each player's list has same numbers with each draw
                CheckResults(player, draw.LuckyNumber, draw.FiveNumbers);

                // print the DRAW numbers
                Console.Write("Draw numbers are: ");
                foreach (int num in draw.FiveNumbers)
                {
                    Console.Write($"{num}.");
                }
                Console.WriteLine(" And The Lucky Number is : " + draw.LuckyNumber);

                // print the result for each loop
                PrintMyResults();

                // call from DrawBudget class a method to get the money every player won in each Draw
                DrawBudget.WinnerMoney(DrawBudget.budget);
            }
            Console.WriteLine("\n");
        }
Пример #2
0
        // method for the money each category wins and the calculation of the budget
        public static double WinnerMoney(double newBudget)
        {
            var moneyPerRound = new DrawBudget();
            var budgetForNext = newBudget;

            if (Result.fivePlus1 != 0)
            {
                moneyPerRound.fiveplus1 = (budget * 0.4) / Result.fivePlus1;
                budgetForNext          -= moneyPerRound.fiveplus1 * Result.fivePlus1;
                Console.WriteLine("Money earned for 5+1: {0}", moneyPerRound.fiveplus1);
            }
            if (Result.fivePlus0 != 0)
            {
                moneyPerRound.fiveplus0 = (budget * 0.25) / Result.fivePlus0;
                budgetForNext          -= moneyPerRound.fiveplus0 * Result.fivePlus0;
                Console.WriteLine("Money earned for 5+0: {0}", moneyPerRound.fiveplus0);
            }
            if (Result.fourPlus1 != 0)
            {
                moneyPerRound.fourplus1 = (budget * 0.15) / Result.fourPlus1;
                budgetForNext          -= moneyPerRound.fourplus1 * Result.fourPlus1;
                Console.WriteLine("Money earned for 4+1: {0}", moneyPerRound.fourplus1);
            }
            if (Result.fourPlus0 != 0)
            {
                moneyPerRound.fourplus0 = (budget * 0.05) / Result.fourPlus0;
                budgetForNext          -= moneyPerRound.fourplus0 * Result.fourPlus0;
                Console.WriteLine("Money earned for 4+0: {0}", moneyPerRound.fourplus0);
            }
            if (Result.threePlus1 != 0)
            {
                moneyPerRound.threeplus1 = (budget * 0.05) / Result.threePlus1;
                budgetForNext           -= moneyPerRound.threeplus1 * Result.threePlus1;
                Console.WriteLine("Money earned for 3+1: {0}", moneyPerRound.threeplus1);
            }
            if (Result.threePlus0 != 0)
            {
                moneyPerRound.threeplus0 = (budget * 0.04) / Result.threePlus0;
                budgetForNext           -= moneyPerRound.threeplus0 * Result.threePlus0;
                Console.WriteLine("Money earned for 3+0: {0}", moneyPerRound.threeplus0);
            }
            if (Result.twoPlus1 != 0)
            {
                moneyPerRound.twoplus1 = (budget * 0.035) / Result.twoPlus1;
                budgetForNext         -= moneyPerRound.twoplus1 * Result.twoPlus1;
                Console.WriteLine("Money earned for 2+1: {0}", moneyPerRound.twoplus1);
            }
            if (Result.twoPlus0 != 0)
            {
                moneyPerRound.twoplus0 = (budget * 0.015) / Result.twoPlus0;
                budgetForNext         -= moneyPerRound.twoplus0 * Result.twoPlus0;
                Console.WriteLine("Money earned for 2+0: {0}", moneyPerRound.twoplus0);
            }
            if (Result.onePlus1 != 0)
            {
                moneyPerRound.oneplus1 = (budget * 0.01) / Result.onePlus1;
                budgetForNext         -= moneyPerRound.oneplus1 * Result.onePlus1;
                Console.WriteLine("Money earned for 1+1: {0}", moneyPerRound.oneplus1);
            }

            return(budget = addBudget(1000) + budgetForNext);
        }
Пример #3
0
        public static void LetsPlay()
        {
            // ask how many players want to join our game
            Console.Write("Give me number of players: ");
            int num_players = Convert.ToInt32(Console.ReadLine());

            // ask the number of DRAWS we're going to have
            Console.Write("Give me number of draws: ");
            int num_of_draws = Convert.ToInt32(Console.ReadLine());

            // use a loop to create PLAYERS and all of them are inside our playerList
            // each player have 5 random numbers and one random lucky number
            // and then print the result of each player
            var playerList = new List <Player>();

            for (int i = 1; i <= num_players; i++)
            {
                var    playerNumbers = Player.RandomList(5, 1, 46);
                var    luckyNumber   = Player.RandomLuckyNumber();
                Player player        = new Player(i)
                {
                    FiveNumbers = playerNumbers,
                    LuckyNumber = luckyNumber
                };

                Thread.Sleep(1000);
                playerList.Add(player);
                Console.WriteLine("User {0} numbers are: {1} - {2} - {3} - {4} - {5}", i, playerNumbers[0],
                                  playerNumbers[1], playerNumbers[2], playerNumbers[3], playerNumbers[4]);
                Console.WriteLine("And lucky number is: {0}", luckyNumber);
            }
            Console.WriteLine("\n");

            // use a loop to create DRAWS and all of them are inside our drawList as did in players above
            // each draw have 5 random numbers and one random lucky number
            // and then print the result of each draw
            var drawList = new List <Draw>();

            for (int i = 1; i <= num_of_draws; i++)
            {
                var  drawNumbers = Draw.DrawList(5, 1, 46);
                var  drawLucky   = Draw.DrawLuckyNumber();
                Draw draw        = new Draw(i)
                {
                    FiveNumbers = drawNumbers,
                    LuckyNumber = drawLucky
                };

                Thread.Sleep(500);
                drawList.Add(draw);
                Console.WriteLine("Draw {0} numbers are: {1} - {2} - {3} - {4} - {5}", i, drawNumbers[0],
                                  drawNumbers[1], drawNumbers[2], drawNumbers[3], drawNumbers[4]);
                Console.WriteLine("And Draw Lucky number is: {0}", drawLucky);
            }
            Console.WriteLine("\n");

            // assign a variable to call the static method with the starting budget of each Draw
            var startBudget = DrawBudget.addBudget(1000);

            // from RESULT class we use static method DrawChecking and as parameter
            // put the lists we create above and then we get the right result for each draw
            Result.DrawChecking(drawList, playerList);

            // use a static method from class CommonNumber to get the 3 most common and the 3 less common
            // numbers of our list of draws and print the results!!!
            CommonNumber.MostCommonNumber();
            CommonNumber.most_common_Array = CommonNumber.most_common_List.ToArray();
            Console.Write("Most Common Numbers are: ");
            for (int i = 0; i < 3; i++)
            {
                Console.Write("{0} ", CommonNumber.most_common_Array[i]);
            }
            Console.WriteLine("\n");
            Console.Write("Less Common Numbers are: ");
            for (int i = CommonNumber.most_common_Array.Length - 1; i > CommonNumber.most_common_Array.Length - 4; i--)
            {
                Console.Write("{0} ", CommonNumber.most_common_Array[i]);
            }
            Console.WriteLine("\n");

            // use a static method from class CommonNumber to get the 3 most common and the 3 less common
            // lucky numbers of our list of drawsand print the results!!!
            CommonNumber.MostCommonLuckyNumber();
            CommonNumber.most_common_Tzoker_Array = CommonNumber.most_common_Tzoker_List.ToArray();
            Console.Write("Most Common Lucky Numbers are: ");
            for (int i = 0; i < 3; i++)
            {
                Console.Write("{0} ", CommonNumber.most_common_Tzoker_Array[i]);
            }
            Console.WriteLine("\n");
            Console.Write("Less Common Lucky Numbers are: ");
            for (int i = CommonNumber.most_common_Tzoker_Array.Length - 1; i > CommonNumber.most_common_Tzoker_Array.Length - 4; i--)
            {
                Console.Write("{0} ", CommonNumber.most_common_Array[i]);
            }
            Console.WriteLine("\n");
        }