示例#1
0
        public async Task MainAsync()
        {
            _client = new DiscordSocketClient();
            _config = BuildConfig();
            var services = ConfigureServices();

            services.GetRequiredService <LogService>();
            await services.GetRequiredService <CommandHandlingService>().InitializeAsync(services);

            LottoList.TicketCount = new List <InfoModule.lotto>();
            LottoList             =
                JsonConvert.DeserializeObject <LottoNumbers>(File.ReadAllText(Directory.GetCurrentDirectory() + @"\test.json"));
            foreach (var x in LottoList.TicketCount)
            {
                for (int i = 0; i < x.Count; i++)
                {
                    InfoModule.lottotickets.Add(x.Name);
                }
            }
            await _client.LoginAsync(TokenType.Bot, _config["token"]);

            await _client.StartAsync();

            await Task.Delay(-1);
        }
示例#2
0
        static void Main(string[] args)
        {
            // A lotto numbers object which is initialized with the total amount of random numbers.
            var _lottoNumbers = new LottoNumbers(QTY);

            Random _random = new Random();

            int _count        = QTY;    // Iterator
            int _randomNumber = -1;     // Stores the random number

            // As long as there is still slots available, add a new random number
            while (_count > 0)
            {
                // Get a random number
                _randomNumber = _random.Next(1, 100);

                // Attempt to add the number to the lotto numbers
                if (_lottoNumbers.Add(_randomNumber) == true)
                {
                    // It was successful, reduce the count by 1
                    _count--;
                }
                // Otherwise, try again until a unique value is found.
            }

            // Display the result
            Console.WriteLine(_lottoNumbers.ToString());
            Console.ReadLine();
        }
示例#3
0
        public ActionResult Index()
        {
            List <LottoNumbers> lottoNumbers = new List <LottoNumbers>();
            XmlDocument         lottery      = new XmlDocument();

            lottery.Load(Server.MapPath("~/Content/xml/lotto1.xml")); //Load xml
            int[] numCommon = new int[7];
            int[] tempCommon = new int[38];                           //37 numbers in array
            int[] tempStrong = new int[8];                            //for strong number
            int   strongNumber = 0, lotteryNumber = 0;

            //Loop through the selected Nodes.
            foreach (XmlNode node in lottery.SelectNodes("/lottery-data/lottery"))
            {
                //Fetch the Node values and assign it to Model.
                LottoNumbers lot = new LottoNumbers();
                lot.num1         = int.Parse(node["num1"].InnerText);
                lot.num2         = int.Parse(node["num2"].InnerText);
                lot.num3         = int.Parse(node["num3"].InnerText);
                lot.num4         = int.Parse(node["num4"].InnerText);
                lot.num5         = int.Parse(node["num5"].InnerText);
                lot.num6         = int.Parse(node["num6"].InnerText);
                lot.strongNumber = int.Parse(node["strong"].InnerText);
                lottoNumbers.Add(lot);
                lotteryNumber++;
                tempCommon[lot.num1]++; tempCommon[lot.num2]++;
                tempCommon[lot.num3]++; tempCommon[lot.num4]++;
                tempCommon[lot.num5]++; tempCommon[lot.num6]++;
                tempStrong[lot.strongNumber]++;
            }
            DBkeeper dbKeeper = new DBkeeper();

            dbKeeper.lottoNumbers   = lottoNumbers;
            dbKeeper.numAppearance  = tempCommon;
            dbKeeper.numAppearance2 = tempCommon.OfType <int>().ToList();;
            numCommon    = LottoNumbers.FindKBiggestNumbers(tempCommon, 6); //find 6 common numbers (1 to 38)
            strongNumber = LottoNumbers.FindStrongNumber(tempStrong);       //find strong number (1 to 7)

            dbKeeper.numCommon     = numCommon;                             //keep common numbers
            dbKeeper.strongNumber  = strongNumber;                          //keep strong number
            dbKeeper.lotteryNumber = lotteryNumber;                         //keep number of lotteries
            dbKeeper.strongArray   = tempStrong;                            //keep strong numbers appearance
            return(View(dbKeeper));
        }
示例#4
0
        private static void Main(string[] args)
        {
#if DEBUG
            #region Functional-Main
            // Functional:
            List <int> lottoNumbers = new List <int>();
            Random     rnd          = new Random();

            while (lottoNumbers.Count < 6)
            {
                int nextLottoNumber = rnd.Next(1, 49);

                if (!lottoNumbers.Contains(nextLottoNumber))
                {
                    lottoNumbers.Add(nextLottoNumber);
                }
            }

            Program.SelectionSort(ref lottoNumbers);

            for (int i = 0; i < 6; i++)
            {
                Console.Write(lottoNumbers[i] + " ");
            }
            #endregion Functional-Main
#else
            #region OOP-Main
            // OOP:
            IRandomNumbers randomNumbers = new LottoNumbers();

            List <int> lottoNumbers = randomNumbers.RandomNumbers;

            foreach (int number in lottoNumbers)
            {
                Console.Write(number + " ");
            }
            #endregion OOP-Main
#endif

            Console.Write("\nEnd");
            Console.ReadKey();
        }