Exemplo n.º 1
0
        static void Main()
        {
            #region Bubble Sort
            Console.WriteLine("Bubble Sort");
            var bubbleSort        = new BubbleSort();
            var bubbleSortContext = new Context(bubbleSort);

            bubbleSortContext.Sort();
            bubbleSortContext.PrintArray();
            #endregion

            #region Insertion Sort
            Console.WriteLine("Insertion Sort");
            var insertionSort        = new InsertionSort();
            var insertionSortContext = new Context(insertionSort);

            insertionSortContext.Sort();
            insertionSortContext.PrintArray();
            #endregion

            #region Selection Sort
            Console.WriteLine("Selection Sort");
            var selectionSort        = new SelectionSort();
            var selectionSortContext = new Context(selectionSort);

            selectionSortContext.Sort();
            selectionSortContext.PrintArray();
            #endregion

            Console.ReadKey();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            int[]        arr1    = { 31, 15, 10, 2, 4, 2, 14, 23, 12, 66 };
            StrategySort sort    = new SelectionSort();
            Context      context = new Context(sort, arr1);

            context.Sort();
            context.PrintArray();

            int[] arr2 = { 1, 5, 10, 2, 4, 12, 14, 23, 12, 66 };
            sort    = new InsertionSort();
            context = new Context(sort, arr2);
            context.Sort();
            context.PrintArray();

            int[] arr3 = { 1, 5, 10, 2, 4, 12, 14, 23, 12, 66 };
            sort    = new BubbleSort();
            context = new Context(sort, arr3);
            context.Sort();
            context.PrintArray();

            Navigator navigator = new Navigator();

            navigator.Execute();
        }
Exemplo n.º 3
0
        static void Main()
        {
            var sort    = new SelectionSort();
            var context = new Context(sort);

            context.Sort();
            context.PrintArray();
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            var sort    = new BubbleSort();
            var context = new Context(sort);

            context.Sort();
            context.PrintArray();
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            Strategy bubbleStrategy = new BubbleSortStrategy();
            Strategy quickStrategy  = new QuickSortStrategy();

            List <int> list = new List <int>();

            list.Add(12);
            list.Add(90);
            list.Add(12);
            list.Add(5);
            list.Add(2);

            Context context = new Context();

            context.SetSortStrategy(bubbleStrategy);
            context.Sort(list);

            context.SetSortStrategy(quickStrategy);
            context.Sort(list);

            Console.ReadKey();
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            int[] arr1 = { 31, 15, 10, 2, 4, 2, 14, 23, 12, 66 };

            StrategySort sort    = new SelectionSort();
            Context      context = new Context(sort, arr1);

            context.Sort();
            context.PrintArray();

            int[] arr2 = { 1, 5, 10, 2, 4, 12, 14, 23, 12, 66 };

            sort    = new InsertionSort();
            context = new Context(sort, arr2);
            context.Sort();
            context.PrintArray();
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            int[]        arr1    = { 31, 15, 10, 2, 4, 2, 14, 23, 12, 66 };
            StrategySort sort    = new SelectionSort();
            Context      context = new Context(sort, arr1);

            context.Sort();
            context.PrintArray();

            int[] arr2 = { 1, 5, 10, 2, 4, 12, 14, 23, 12, 66 };
            sort    = new InsertionSort();
            context = new Context(sort, arr2);
            context.Sort();
            context.PrintArray();

            int[] arr3 = { 6, 3, 8, 1, 2, 9, 4, 5, 7 };
            sort    = new BubbleSort();
            context = new Context(sort, arr3);
            context.Sort();
            context.PrintArray();

            Console.ReadKey();
        }