-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHRmenu.java
More file actions
107 lines (95 loc) · 3.61 KB
/
HRmenu.java
File metadata and controls
107 lines (95 loc) · 3.61 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
96
97
98
99
100
101
102
103
104
105
106
import java.util.Scanner;
import java.util.Set;
/**
* <h3> COMP90041, Sem2, 2022: Final Project </h3>
* <p> Class HRmenu has methods to get user input from command line input and to display option menu
* @author Gia Han Ly
*
*/
public class HRmenu {
// Set of available inputs
private static final Set<String> CHOICE = Set.of("create", "jobs", "quit", "c", "j", "q", "applications", "a",
"matchmaking", "m", "filter", "f");
private Jobs jobs = new Jobs();
private Applicant applications = new Applicant();
private Scanner keyboard = new Scanner(System.in);
private Applied applied = new Applied();
private Filter filter = new Filter();
private Matchmaker match = new Matchmaker();
// Constructors
/**
* Constructor for HRMenu object
* @param jobsFile jobs file name
* @param applicationsFile applications file name
*/
public HRmenu(String jobsFile, String applicationsFile){
jobs.read(jobsFile);
applications.read(applicationsFile);
}
/**
* Take input from user and run the required methods. Methods options are: quit, create jobs, list jobs, list applicants, filter and matchmaking
*/
public void getInput(){
String input;
menu();
// Take in user input and run the required method
while (true){
input = keyboard.nextLine();
if (!CHOICE.contains(input)){
System.out.print("Invalid input! Please enter a valid command to continue: \n> ");
}
if (input.equals("c") || input.equals("create")){
//Create new job and save in jobs file
jobs = jobs.create(keyboard);
jobs.saveJobs(jobs);
menu();
}
if (input.equals("q") || input.equals("quit")){
return;
}
if (input.equals("j") || input.equals("jobs")){
// Display jobs with applicants applied for the job
applied.display();
menu();
}
if (input.equals("a") || input.equals("applicants")){
// Display applicants
filter.sortDefault();
applications.applicantAvailable();
menu();
}
if (input.equals("f") || input.equals("filter")){
// Take in required filter and output applicants
System.out.print("Filter by: [lastname], [degree] or [wam]: ");
filter.getInput(keyboard);
menu();
}
if (input.equals("m") || input.equals("matchmaking")){
if (Applicant.getNumberOfApplicant() == 0 || Applied.getAppliedList().size() == 0){
System.out.println("No applicants available.");
}
else if (Jobs.getNumberofJobs() == 0){
System.out.println("No jobs available.");
}
match.saveMatches();
Matchmaker.printMatches();
menu();
}
}
}
/**
* Print menu options
*/
private void menu(){
String menu = Applicant.getNumberOfApplicant() +" applications received.\n" +
"Please enter one of the following commands to continue:\n" +
"- create new job: [create] or [c]\n" +
"- list available jobs: [jobs] or [j]\n" +
"- list applicants: [applicants] or [a]\n" +
"- filter applications: [filter] or [f]\n" +
"- matchmaking: [match] or [m]\n" +
"- quit the program: [quit] or [q]\n" +
"> ";
System.out.print(menu);
}
}