Esempio n. 1
0
        public Data.Powerball AddPick()
        {
            var powerball = new Data.Powerball();
            var file      = new Data.FileRepo();


            for (int i = 0; i < 5; i++)
            {
                bool contain = true;
                while (contain == true)
                {
                    int input = ReadIntInRange($"Please enter in a number between 1-69 for Set {i + 1}: ", 1, 69);

                    if (powerball.Nmbers.Contains(input))
                    {
                        Console.WriteLine("Please enter in a unique number!");
                        contain = true;
                    }
                    else
                    {
                        powerball.Nmbers.Add(input);
                        contain = false;
                    }
                }
            }


            int powerInput = ReadIntInRange($"Please enter in a number between 1-26 for your Powerball Number: ", 1, 26);

            powerball.Powerballnum = powerInput;

            // this part is going to set the id, which means grabbing the file and finding the max of all ids.

            var max = file.ReadFile();



            int count = max.Count();

            if (count == 0)
            {
                powerball.ID = 1;
            }
            else if (count > 0)
            {
                var maxID = max.Max(m => m.ID);
                powerball.ID = maxID + 1;
            }
            //now this will write the file

            file.WriteFile(powerball);

            Console.WriteLine($"This is your ID for the ticket you just created: {powerball.ID}");
            Console.ReadKey();

            return(powerball);
        }