-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMatchRelationship.java
227 lines (173 loc) · 6.97 KB
/
MatchRelationship.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
public class MatchRelationship {
private StudentProfile student;
private Scholarship scholarship;
private int ID;
private float matchPercentage;
private float matchIndex;
private HashMap<String, String> application = new HashMap<String, String>();
private String applicationStatus;
private Boolean isActive;
// input string of application questions into a hashmap as the keys
public HashMap<String, String> InitializeApplication(ArrayList<String> applicationQuestions) {
HashMap<String, String> application = new HashMap<String, String>();
for (int i = 0; i < applicationQuestions.size(); i++) {
application.put(applicationQuestions.get(i), "");
}
return application;
}
// update application hashmap with answer values
public HashMap<String, String> UpdateApplication(ArrayList<String> applicationQandA) {
HashMap<String, String> application = new HashMap<String, String>();
for (int i = 0; i < applicationQandA.size(); i = i + 2) {
if (applicationQandA.get(i + 1).equals("*")){
application.put(applicationQandA.get(i), "");
}
else{
application.put(applicationQandA.get(i), applicationQandA.get(i + 1));
}
}
return application;
}
// initialize additional requirement questions hashmap with requirements as keys
public HashMap<String, String> InitializeAdditionalRequirements(ArrayList<String> additionalRequirementQs) {
HashMap<String, String> additionalRequirements = new HashMap<String, String>();
for (int i = 0; i < additionalRequirementQs.size(); i++) {
application.put(additionalRequirementQs.get(i), "");
}
return additionalRequirements;
}
public HashMap<String, String> UpdateAdditionalRequirements(ArrayList<String> additionalRequirementsQandA) {
HashMap<String, String> additionalRequirements = new HashMap<String, String>();
for (int i = 0; i < additionalRequirementsQandA.size(); i = i + 2) {
additionalRequirements.put(additionalRequirementsQandA.get(i), additionalRequirementsQandA.get(i + 1));
}
return additionalRequirements;
}
// need method to compare scholarship requirements with student requirements
// constructors
//for typed input
public MatchRelationship(StudentProfile inputStudent, Scholarship inputScholarship, float inputMatchPercentage,
float inputMatchIndex, int ID) {
this.student = inputStudent;
this.scholarship = inputScholarship;
this.matchPercentage = inputMatchPercentage;
this.matchIndex = inputMatchIndex;
this.application = InitializeApplication(inputScholarship.getApplication());
this.applicationStatus = "not started";
this.ID = ID;
this.isActive = true;
}
//for file read input
public MatchRelationship(StudentProfile inputStudent, Scholarship inputScholarship, int ID, float inputMatchPercentage,
float inputMatchIndex, ArrayList<String> application, String applicationStatus, Boolean isActive) {
this.student = inputStudent;
this.scholarship = inputScholarship;
this.ID = ID;
this.matchPercentage = inputMatchPercentage;
this.matchIndex = inputMatchIndex;
this.application = UpdateApplication(application);
this.applicationStatus = applicationStatus;
this.isActive = isActive;
}
public MatchRelationship() {
}
// getters
public float getMatchPercentage() {
return this.matchPercentage;
}
public float getMatchIndex() {
return this.matchIndex;
}
public String getApplicationStatus() {
return this.applicationStatus;
}
public HashMap<String, String> getApplication() {
return this.application;
}
public String getStudentName() {
return this.student.getName();
}
public Boolean getIsActive() {
return isActive;
}
public String getScholarshipName() {
return this.scholarship.getName();
}
public int getID() {
return this.ID;
}
public Scholarship getScholarship() {
return this.scholarship;
}
// setters
public void setMatchPercentage(float inputMatchPercentage) {
this.matchPercentage = inputMatchPercentage;
}
public void setMatchIndex(float inputMatchIndex) {
this.matchIndex = inputMatchIndex;
}
public void setApplicationToInProgress() {
this.applicationStatus = "in progress";
}
public void setApplicationToSubmitted() {
this.applicationStatus = "submitted";
}
public void setIsActive(Boolean isActive) {
this.isActive = isActive;
}
public void setApplication(ArrayList<String> inputApplication) {
try {
if (inputApplication.size() % 2 != 0) {
throw new Exception(
"Uneven answer-question pairings!\nPlease enter an empty string for any unanswered questions.");
}
this.application = UpdateApplication(inputApplication);
}
catch (Exception except) {
System.out.println(except.getMessage());
}
}
public String getDetailsFileText() {
return this.student.getName() + "\n"
+ this.scholarship.getName() + "\n"
+ this.matchPercentage + "\n"
+ this.matchIndex + "\n"
+ this.applicationStatus + "\n"
+ this.isActive;
}
public String getApplicationFileText() {
ArrayList<String> applicationList = new ArrayList<String>();
//pass string of line seperated values
//pass a star if answer is empty
for (HashMap.Entry<String, String> entry : this.application.entrySet()) {
applicationList.add(entry.getKey());
if (entry.getValue() == "") {
applicationList.add("*");
}
else {
applicationList.add(entry.getValue());
}
}
String fileText = String.join("\n", applicationList);
return fileText;
}
public String getDetailsString() {
String info = "Scholarship Name: " + getScholarshipName() + "\n";
info += "Student Name: " + getStudentName() + "\n";
info += "Match percentage: " + String.format("%.1f", this.matchPercentage) + "%\n";
info += "Match Index: " + String.format("%.2f", this.matchIndex) + "\n";
info += "Current application: \n";
int qIndex = 1;
for (Map.Entry<String, String> pair : this.application.entrySet()) {
info += "Question " + qIndex + ": ";
info += pair.getKey() + "\n";
info += pair.getValue() + "\n";
qIndex++;
}
info += "Status of application: " + this.applicationStatus;
return info;
}
}