示例#1
0
        static void Main(string[] args)
        {
            int option;
            NumberCollection nc = new NumberCollection();

            nc.Add(1);
            nc.Add(2);
            nc.Add(3);
            nc.Add(4);
            nc.Add(5);
            nc.Add(-5);

            do
            {
                Console.WriteLine("What would you like to do?");
                Console.WriteLine("1 - Sort the array");
                Console.WriteLine("2 - Multiply the array by 2");
                Console.WriteLine("3 - Exit");
                option = Int32.Parse(Console.ReadLine());

                if (option == 1)
                {
                    nc.Sort();
                }
                else if (option == 2)
                {
                    nc.Multiply();
                }

                Console.WriteLine(nc.ToString());
            } while (option != 3);
        }
示例#2
0
        static void Main(string[] args)
        {
            NumberCollection myCollection = new NumberCollection();

            for (int i = 1; i <= 12; i++)
            {
                myCollection.AddNumber(i);
                myCollection.Sort(myCollection.GetNumbers());
            }

            for (int i = 12; i >= 7; i--)
            {
                myCollection.RemoveNumber(i);
                myCollection.Sort(myCollection.GetNumbers());
            }
        }
示例#3
0
        static void Main(string[] args)
        {
            NumberCollection nc = new NumberCollection();

            nc.Add(1);
            nc.Add(2);
            nc.Add(3);
            nc.Add(4);
            nc.Add(5);
            nc.Add(6);
            nc.Add(7);
            nc.Add(8);
            nc.Add(9);

            nc.Sort();

            nc.Add(10);
            nc.Add(11);
            nc.Sort();
        }