예제 #1
0
        /// <summary>
        /// Creates an IntegerSet based off of user input
        /// </summary>
        /// <returns>returns an IntegerSet created by a user</returns>
        private static IntegerSet InputSet()
        {
            IntegerSet set = new IntegerSet();
            int        val = 0;
            String     userInput;

            while (val >= 0)
            {
                Console.WriteLine("Enter an integer 0-100 or a negative integer to end the program");
                userInput = Console.ReadLine();
                val       = Convert.ToInt32(userInput);
                if (val <= 100 && val >= 0)
                {
                    set.InsertElement(val);
                }
                else
                {
                    Console.WriteLine("Input out of range, was not included in set");
                }
            }

            return(set);
        }