private void btn_run_Click(object sender, RoutedEventArgs e)
        {
            WhiteBall whiteBall = new WhiteBall("WhiteBall"); //set up ball objects
            BlackBall blackBall = new BlackBall("BlackBall");
            Ball winner = new Ball();

            Random rand = new Random();//get a random number
            int random = rand.Next(0, 11);

            if (random <= 5) { winner = whiteBall; }//see which ball wins
            if (random >= 6) { winner = blackBall; }

            MessageBox.Show(random.ToString());//display winner
            MessageBox.Show(winner.getName());
        }
Пример #2
0
        private void btn_run_Click(object sender, RoutedEventArgs e)
        {
            WhiteBall whiteBall = new WhiteBall("WhiteBall"); //set up ball objects
            BlackBall blackBall = new BlackBall("BlackBall");
            Ball      winner    = new Ball();

            Random rand   = new Random();//get a random number
            int    random = rand.Next(0, 11);

            if (random <= 5)
            {
                winner = whiteBall;
            }                                       //see which ball wins
            if (random >= 6)
            {
                winner = blackBall;
            }

            MessageBox.Show(random.ToString());//display winner
            MessageBox.Show(winner.getName());
        }