//Generate 5 random numbers, sort and display on button click.
        private void button1_Click(object sender, EventArgs e)
        {
            numHolder = new NumberHolder();
            for (int i = 0; i < 5; i++)
            {
                int number = numGen.generateNum();
                if (!numHolder.isDuplicate(number))
                    numHolder.addToArray(number);
                else
                {
                    i--;
                    number = numGen.generateNum();
                }
            }

            //Sort numbers in array.
            Array.Sort(numHolder.NumbersArray);

            //Output
            output();
        }
Beispiel #2
0
        //Generate 5 random numbers, sort and display on button click.
        private void button1_Click(object sender, EventArgs e)
        {
            numHolder = new NumberHolder();
            for (int i = 0; i < 5; i++)
            {
                int number = numGen.generateNum();
                if (!numHolder.isDuplicate(number))
                {
                    numHolder.addToArray(number);
                }
                else
                {
                    i--;
                    number = numGen.generateNum();
                }
            }

            //Sort numbers in array.
            Array.Sort(numHolder.NumbersArray);

            //Output
            output();
        }