-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOrdenar.java
104 lines (73 loc) · 2.21 KB
/
Ordenar.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package trabalhoGrauB1;
import java.util.LinkedList;
import java.util.Scanner;
public class Ordenar {
private static Scanner input;
public Ordenar () {
input = new Scanner(System.in);
}
public static boolean confirm(String name, String description)
{
int option;
boolean confirm = false;
System.out.println("\n" + name);
System.out.println(description);
do {
System.out.println("\n1: Confirmar | 2: Cancelar");
System.out.print("O que deseja fazer: ");
option = input.nextInt();
if (option == 1) {
confirm = true;
} else if (option == 2) {
confirm = false;
} else {
System.out.println("Opção inválida.\n");
}
} while(option != 1 && option != 2);
return confirm;
}
public void quickSort(LinkedList<Integer> list) {
QuickSort quickSort = new QuickSort();
boolean confirm = confirm(quickSort.name, quickSort.description);
if (confirm) {
quickSort.ordenarDados(list, 0, list.size() - 1);
System.out.println("Ordenado com Quick Sort.");
}
}
public void bubbleSort(LinkedList<Integer> list)
{
BubbleSort bubbleSort = new BubbleSort();
boolean confirm = confirm(bubbleSort.name, bubbleSort.description);
if (confirm) {
bubbleSort.ordenarDados(list);
System.out.println("Ordenado com Bubble Sort.");
}
}
public void mergeSort(LinkedList<Integer> list)
{
MergeSort mergeSort = new MergeSort();
boolean confirm = confirm(mergeSort.name, mergeSort.description);
if (confirm) {
mergeSort.ordenarDados(list, 0, (list.size() - 1));
System.out.println("Ordenado com Merge Sort.");
}
}
public void selectionSort(LinkedList<Integer> list)
{
SelectionSort selectionSort = new SelectionSort();
boolean confirm = confirm(selectionSort.name, selectionSort.description);
if (confirm) {
selectionSort.ordenarDados(list);
System.out.println("Ordenado com Selection Sort.");
}
}
public void insertionSort(LinkedList<Integer> list)
{
InsertionSort insertionSort = new InsertionSort();
boolean confirm = confirm(insertionSort.name, insertionSort.description);
if (confirm) {
insertionSort.ordenarDados(list);
System.out.println("Ordenado com Insertion Sort.");
}
}
}