Exemplo n.º 1
0
        private void randomTicketButton_Click(object sender, EventArgs e)
        {
            var myTicket = new PowerBallTicket(random);

            myTicketLabel.Text = myTicket.ToString();
            tickets++;
        }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            // checks to see if the sender that triggered the event is a control
            if (sender == button2)
            {
                // basically a Try Cast
                Button button = sender as Button;
                // if it didn't cast, we get null
                if (button != null)
                {
                    button.Text = "You clicked me";
                }

                MessageBox.Show("YOU DID IT!");
                button1.Enabled = true;
                tickets         = 0;
            }

            else
            {
                var numbersString = numbersTextBox.Text;

                var numbersSplit = numbersString.Split();

                if (numbersSplit.Length != 6)
                {
                    myTicketLabel.Text = "Please enter 6 numbers separated by spaces";
                }
                else
                {
                    int[] numbers = new int[6];

                    for (int index = 0; index < numbersSplit.Length; index++)
                    {
                        numbers[index] = Int32.Parse(numbersSplit[index]);
                    }

                    var myTicket = new PowerBallTicket(numbers);

                    myTicketLabel.Text = myTicket.ToString();
                    tickets++;

                    if (tickets == 3)
                    {
                        button1.Enabled = false;
                    }
                }
            }
        }