-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFilter.java
More file actions
95 lines (84 loc) · 2.54 KB
/
Filter.java
File metadata and controls
95 lines (84 loc) · 2.54 KB
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
import java.util.Set;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
/**
* <h3>COMP90041, Sem2, 2022: Final Project</h3>
* <p>Class Filter is used to take in filter requirement and call the approriate method.
* @author Gia Han Ly
*/
public class Filter {
private static final Set<String> FILTERS = Set.of("lastname", "degree", "wam");
private List<Applicant> applications = Applicant.getApplicantsList();
/**
* Take user input and sort based on filter selected
* @param keyboard
*/
public void getInput(Scanner keyboard){
String input;
while(true){
input = keyboard.nextLine();
if (!FILTERS.contains(input)){
System.out.print("Invalid input! Please enter a valid command to continue:\n> ");
}
if (input.equals("lastname")){
sortLastName();
return;
}
if (input.equals("degree")){
sortDegree();
return;
}
if (input.equals("wam")){
sortWAM();
return;
}
}
}
/**
* Sort applicants based on last name
*/
private void sortLastName(){
int i = 1;
List<Applicant> temp = Applicant.getApplicantsList();
Collections.sort(temp,new ApplicantNameComparator());
for (Applicant a : applications){
System.out.print("["+ i +"] ");
Applicant.printApplicant(a);
i++;
}
}
/**
* Sort applicants based on degree
*/
private void sortDegree(){
int i = 1;
List<Applicant> temp = Applicant.getApplicantsList();
Collections.sort(temp, new ApplicantDegreeComparator());
for (Applicant a : applications){
System.out.print("["+ i +"] ");
Applicant.printApplicant(a);
i++;
}
}
/**
* Sort applicants based on WAM
*/
private void sortWAM(){
int i = 1;
Applicant.wamCalc();
List<Applicant> temp = Applicant.getApplicantsList();
Collections.sort(temp, new ApplicantWAMComparator());
for (Applicant a : applications){
System.out.print("["+ i +"] ");
Applicant.printApplicant(a);
i++;
}
}
/**
* Sort applicants based on start date, cut ties by comparing last name, first name
*/
public void sortDefault(){
Collections.sort(applications, new ApplicantDefaultComparator());
}
}