示例#1
0
        static void Main(string[] args)
        {
            Lottery lottery = new Lottery();

            int  hitCounter = 0;
            bool wantToPlay = true;

            lottery.GenerateLotteryTicket();

            while (wantToPlay)
            {
                Console.WriteLine("Gib eine sechsstellige Zahl ein.");
                Console.WriteLine("Wenn du nicht mehr spielen möchtest gib x ein.");
                string userString = Console.ReadLine();
                if (userString.Equals("x"))
                {
                    lottery.ShowRightNumbers();
                    break;
                }
                else
                {
                    hitCounter = lottery.CheckForHits(userString);
                }

                Console.WriteLine("Du hast " + hitCounter + " Zahl(en) richtig erraten!");
                if (hitCounter == 6)
                {
                    Console.WriteLine("Lottosechser. Leider gibts hier kein Geld dafür.");
                    lottery.ShowRightNumbers();
                }
            }
        }
示例#2
0
        // Call interface for modders

        // Create a table
        //   Call(name, weight, predicate);

        // Add a fixed amount to a table
        //   Call(name, weight, ID, amount);

        // Add a variable amount to a table
        //   Call(name, weight, ID, min, max);

        public override object Call(params object[] args)
        {
            PrizeNode table;
            Prize     prize;

            switch (args.Length)
            {
            case 2:
                Lottery.AddTable((string)args[0], (double)args[1], (Func <bool>)args[2], new PrizeNode[] {});
                break;

            case 3:
                Lottery.AddTable((string)args[0], (double)args[1], (Func <bool>)args[2], new PrizeNode[] {});
                break;

            case 4:
                table = Lottery.prizeTables[(string)args[0]];
                prize = new Prize((double)args[1], (int)args[2], (int)args[3]);
                table.AddChildren(prize);
                break;

            case 5:
                table = Lottery.prizeTables[(string)args[0]];
                prize = new Prize((double)args[1], (int)args[2], (int)args[3], (int)args[4]);
                table.AddChildren(prize);
                break;
            }

            return(this);
        }
示例#3
0
 static void Main(string[] args)
 {
     try {
         Lottery lottery = new Lottery(6);
         do
         {
             try {
                 Console.WriteLine("Please, enter lottery number - 6 digits [1-9] or 'exit' to leave");
                 string inp = Console.ReadLine();
                 if (inp.ToUpper() == "EXIT")
                 {
                     return;
                 }
                 if (lottery.CheckWin(inp))
                 {
                     Console.WriteLine("You won!");
                 }
                 else
                 {
                     Console.WriteLine("Sorry, may be another time... Wining number was {0}", lottery.LastWonNum);
                 }
             } catch (ArgumentException ex) {
                 Console.ForegroundColor = ConsoleColor.Red;
                 Console.WriteLine("Please, validate your input: {0}", ex.Message);
                 Console.ResetColor();
             }
         } while (true);
     } catch (Exception ex) {
         Console.WriteLine("Sorry, unhandled exception happened ({0})", ex.Message);
         Console.ReadLine();
     }
 }
示例#4
0
        // ----------------------------------------------------------------------------------------
        // Private methods
        // ----------------------------------------------------------------------------------------

        /// <summary>
        /// Show options selected

        private static void showOptionSelected(int option, Lottery lottery)
        {
            Console.Clear();

            switch (option)
            {
            case 1:
                lottery.AddManualBet();
                break;

            case 2:
                lottery.AddAutoBet();
                break;

            case 3:
                lottery.ShowMap();
                break;

            case 4:
                lottery.ValidateLottery();
                break;

            case 5:
                // Does nothing.
                break;

            default:
                Console.WriteLine("Selecione uma opção válida! \n");
                break;
            }
        }
示例#5
0
        // ----------------------------------------------------------------------------------------
        // Main methods
        // ----------------------------------------------------------------------------------------

        /// <summary>
        /// Main method
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            // Local variables
            int     option;
            Lottery lottery = new Lottery();

            // Configurations with properties
            // lottery.Max = 10;

            do
            {
                Console.WriteLine("");

                // Options menu
                Console.WriteLine("Selecione a opção");
                Console.WriteLine("\t 1 - Inserir novo jogo (manual)");
                Console.WriteLine("\t 2 - Inserir novo jogo (automático)");
                Console.WriteLine("\t 3 - Jogos realizados");
                Console.WriteLine("\t 4 - Sortear");
                Console.WriteLine("\t 5 - Sair");

                option = Util.ConsoleReadNumber();

                showOptionSelected(option, lottery);
            } while (option != 5);
        }
示例#6
0
        public Lottery()
        {
            Properties = new ModProperties()
            {
                Autoload = true
            };

            Lottery.AddBuiltinTables();
        }
示例#7
0
文件: Program.cs 项目: rpgrca/netcore
        static void Main(string[] args)
        {
            Lottery lottery = new Lottery(1, 1, 5);

            lottery.AddPlayer(new Player("Juan", lottery.Values, lottery.MinValue, lottery.MaxValue));
            lottery.AddPlayer(new Player("Nancy", lottery.Values, lottery.MinValue, lottery.MaxValue));
            lottery.AddPlayer(new Player("Martin", lottery.Values, lottery.MinValue, lottery.MaxValue));

            lottery.Draw();
        }
示例#8
0
 private static void AddBuiltinTables()
 {
     Lottery.AddTable("easymode", 0.33, () => true, BuiltinTables.BuildEasymode());
     Lottery.AddTable("hardmode", 0.33, () => Main.hardMode, BuiltinTables.BuildHardmode());
     Lottery.AddTable("expertmode", 0.33, () => Main.expertMode, BuiltinTables.BuildExpertmode());
 }
示例#9
0
 public static void AddTable(string name, double weight)
 {
     Lottery.AddTable(name, weight, new PrizeNode[] {});
 }
示例#10
0
 public static void AddTable(string name, double weight, PrizeNode[] entries)
 {
     Lottery.AddTable(name, weight, () => true, new PrizeNode[] {});
 }
示例#11
0
 private void button1_Click(object sender, EventArgs e)
 {
     int mV = int.Parse(textBox1.Text);
     int wN = int.Parse(textBox2.Text);
     lottery = new Lottery(mV, wN);
 }