Esempio n. 1
0
        public static ISortingStrategy GetSortingStrategy(ObjectToSort objectToSort)
        {
            ISortingStrategy sortingStrategy = null;

            switch (objectToSort)
            {
                case ObjectToSort.StudentNumber:
                    sortingStrategy = new MergeSort();
                    break;
                case ObjectToSort.RailwayPassangers:
                    sortingStrategy = new HeapSort();
                    break;
                case ObjectToSort.CountryResidents:
                    sortingStrategy = new QuickSort();
                    break;
                default:
                    throw new ArgumentOutOfRangeException("Unsupported object to sort");
            }

            return sortingStrategy;
        }
            internal static string GetAlgo(ObjectToSort objectToSort)
            {
                switch (objectToSort)
                {
                case ObjectToSort.StudentNumber:
                    //Merge sort Algo
                    return("Merge Sort");

                case ObjectToSort.RailwayPassengers:
                    //HeapSort Algo
                    return("Heap Sort");

                case ObjectToSort.CountyResidents:
                    //QuickSort Algo
                    return("Quick Sort");

                default:
                    break;
                }

                return("No sorting Algo");
            }
Esempio n. 3
0
        private static ISortingStrategy GetSortingOption(ObjectToSort objectToSort)
        {
            ISortingStrategy sortingStrategy = null;

            switch (objectToSort)
            {
            case ObjectToSort.StudentNumber:
                sortingStrategy = new MergeSort();
                break;

            case ObjectToSort.RailwayPassengers:
                sortingStrategy = new HeapSort();
                break;

            case ObjectToSort.CountyResidents:
                sortingStrategy = new QuickSort();
                break;

            default:
                break;
            }
            return(sortingStrategy);
        }