package sort.test; import sort.manysort.BubbleSort; import sort.manysort.ExchangeSort; import sort.manysort.InsertionSort; import sort.manysort.SelectionSort; import sort.manysort.ShellSort; public class SortManager implements TimeChecker { private Command[] commands = { new BubbleSort(), new ExchangeSort(), new SelectionSort(), new InsertionSort(), new ShellSort() }; private Command command; private long start, end; private long delay; public SortManager() { } public Command[] getCommands() { return this.commands; } public Command findCommand(String name) { // Ŭ·¡½º ã±â for (int i = 0; i < commands.length; i++) { if (commands[i].getName().equals(name)) { return commands[i]; } } return null; } public void setCommand(Command command) { this.command = command; } public void execute(Integer[] S) { // Á¤·Ä ½ÇÇà ¹× ¼öÇà½Ã°£ °è»ê start = System.nanoTime(); command.sorting(S); end = System.nanoTime(); delay = (end - start) / 1000L / 1000L; } public long getDelay() { return delay; } public void printDelay() { System.out.print(" #" + command.getName() + " : [" + delay + "ms] [" + delay / 1000L + "s]"); } }