예제 #1
0
        static void Main(string[] args)
        {
            var input = 0;
            var intro = true;

            var program = new MegaSenaLotteryProgram();

            do
            {
                input = ShowMenu(intro);
                intro = false;

                switch (input)
                {
                case 1:
                    RealizarJogo(program);
                    break;

                case 2:
                    RealizarJogoAutomaticamente(program);
                    break;

                case 3:
                    RealizarSorteio(program);
                    break;

                case 4:
                    Historico(program);
                    break;

                default:
                    break;
                }
            } while (input != 5);
        }
예제 #2
0
        private static void RealizarJogoAutomaticamente(MegaSenaLotteryProgram program)
        {
            var result = program.RegisterAutomaticGame();

            if (result.Success)
            {
                Console.WriteLine();
                Console.WriteLine(result.Content);
                Console.WriteLine();
            }
            else
            {
                Console.WriteLine();
                Console.WriteLine(result.Error);
                Console.WriteLine();
                return;
            }
        }
예제 #3
0
        private static void RealizarSorteio(MegaSenaLotteryProgram program)
        {
            var result = program.DoLottery();

            if (result.Success)
            {
                Console.WriteLine();
                Console.WriteLine(result.Content);
                Console.WriteLine();
            }
            else
            {
                Console.WriteLine();
                Console.WriteLine(result.Error);
                Console.WriteLine();
                return;
            }
        }
예제 #4
0
        private static void Historico(MegaSenaLotteryProgram program)
        {
            var result = program.GetHistory();

            if (result.Success)
            {
                Console.WriteLine();
                Console.WriteLine(result.Content);
                Console.WriteLine();
            }
            else
            {
                Console.WriteLine();
                Console.WriteLine(result.Error);
                Console.WriteLine();
                return;
            }
        }
예제 #5
0
        static void RealizarJogo(MegaSenaLotteryProgram program)
        {
            Console.WriteLine();
            Console.WriteLine("Digite os 6 números separados por ponto e virgula, por favor:");
            var input = Console.ReadLine();

            int[] numbers = null;
            try
            {
                numbers = input.Split(';')
                          .Select(x => Convert.ToInt32(x.TrimStart().TrimEnd()))
                          .ToArray();
            }
            catch (Exception)
            {
                Console.WriteLine();
                Console.WriteLine("Jogo inválido. Tente novamente.");
                Console.WriteLine();
                return;
            }

            var newGame = new MegaSenaGame(numbers);

            var result = program.TryRegisterGame(newGame);

            if (result.Success)
            {
                Console.WriteLine();
                Console.WriteLine(result.Content);
                Console.WriteLine();
            }
            else
            {
                Console.WriteLine();
                Console.WriteLine(result.Error);
                Console.WriteLine();
                return;
            }
        }