⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sorter.java

📁 这是Java的模式编程
💻 JAVA
字号:
package Strategy;
import java.io.*;
public class Sorter
{
	private SortStrategy sortStrategy;
	
	public String[] sort(Comparable[] a)
	{
		sortStrategy.sort(a);
		return sortStrategy.getBack();
	}
	public void setStrategy(String sortStrategy)
	{
		if(sortStrategy.compareTo("BinSort") == 0)
		    this.sortStrategy = new BinSort();
		if(sortStrategy.compareTo("BubbleSort") == 0)
			this.sortStrategy = new BubbleSort();
		if(sortStrategy.compareTo("QuickSort") == 0)
			this.sortStrategy = new QuickSort();
		if(sortStrategy.compareTo("MergeSort") == 0)
			this.sortStrategy = new Mergesort();
		if(sortStrategy.compareTo("HeapSort") == 0)
			this.sortStrategy = new HeapSort();
		if(sortStrategy.compareTo("ShellSort") == 0)
			this.sortStrategy = new ShellSort();
		if(sortStrategy.compareTo("RankSort") == 0)
			this.sortStrategy = new RankSort();
		if(sortStrategy.compareTo("SelectionSort") == 0)
			this.sortStrategy = new SelectionSort();
		
	}


}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -