Exemple #1
0
        static void Main()
        {
            int toDraw = 0;
            int max    = 0;
            List <LotteryDraw> draws = new List <LotteryDraw>();

            for (int i = 0; i < 5; i++)
            {
                Console.Write("Enter the size of the draw: ");
                try
                {
                    max = Convert.ToInt32(Console.ReadLine());
                    draws.Add(new LotteryDraw(max));
                }
                catch (FormatException ex)
                {
                    Console.WriteLine(ex.Message);
                }
                catch (OverflowException ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
            LotteryDrawHistory history = new LotteryDrawHistory();

            foreach (LotteryDraw draw in draws)
            {
                Console.Write("\nHow many numbers do you want to draw? ");
                try
                {
                    toDraw = Convert.ToInt32(Console.ReadLine());
                }
                catch (FormatException ex)
                {
                    Console.WriteLine(ex.Message);
                }
                catch (OverflowException ex)
                {
                    Console.WriteLine(ex.Message);
                }
                draw.DrawNumbers(toDraw);
                history.AddLotteryDraw(draw);
                Console.WriteLine(draw);
            }

            Console.WriteLine(history);
            Console.ReadLine();
        }
Exemple #2
0
        public static void Main()
        {
            try
            {
                LotteryDraw l1 = new LotteryDraw(47);
                LotteryDraw l2 = new LotteryDraw(47);
                LotteryDraw l3 = new LotteryDraw(47);

                //Console.WriteLine(l1.MaxNumber);
                //validated input is as expected

                //l1.Draw(6);
                //Console.WriteLine(l1.ToString());


                //Console.WriteLine(l1.NumbersDrawn.Count());
                //validated list is of correct size (dependent on draw parm)

                //drawing numbers
                l1.Draw(6);
                l2.Draw(6);
                l3.Draw(6);

                LotteryDrawHistory ldh1 = new LotteryDrawHistory();

                ldh1.AddLotteryDraw(l1);
                ldh1.AddLotteryDraw(l2);
                ldh1.AddLotteryDraw(l3);

                Console.WriteLine(ldh1.ToString());

                //Console.WriteLine(ldh1.DrawHistory[0]);

                //frequency outputs sorted collection of int, can currently only
                //scan with eyes to see duplicates
                ldh1.FrequentNum(ldh1.DrawHistory);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }