-
Notifications
You must be signed in to change notification settings - Fork 0
/
Student.java
248 lines (227 loc) · 7.15 KB
/
Student.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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package exchangeallocatorframe;
/* Class: Student.java
* Author: Emiel Verkade - Maastricht University
*
* Description:
* This program outlines the components of the 'Student' object
* created by myself for this specific problem. There are several
* methods designed and implemented with descriptions above the methods
*
*/
public class Student {
private final int Ranking;
private final int StudentNumber;
private String[] Choices;
private int[] NumberChoices;
private University university;
private int UniNumber;
private int ChoiceNumber;
private String StudyTrack;
private double studyAbroadAverage;
private boolean studyAbroadChecked;
private boolean requirementsChecked;
private final boolean[] masterApproval;
private final String firstName;
private final String lastName;
private final String email1;
private final String email2;
private final String prefix;
private final String phoneNumber;
//constructor
public Student() {
this.Ranking = 0;
this.StudentNumber = 0;
this.Choices = null;;
this.NumberChoices = null;
this.university = null;
this.UniNumber = 0;
this.ChoiceNumber = 0;
this.StudyTrack = "";
this.studyAbroadAverage = 0.0;
this.studyAbroadChecked = false;
this.requirementsChecked = false;
this.masterApproval = new boolean[6];
this.firstName = null;
this.lastName = null;
this.email1 = null;
this.email2 = null;
this.prefix = null;
this.phoneNumber = null;
}
// constructor
public Student(int Ranking, int StudentNumber, String firstName, String lastName, String prefix, String phoneNumber, String email1, String email2, String[] Choices) {
this.Ranking = Ranking;
this.StudentNumber = StudentNumber;
this.Choices = Choices;
this.NumberChoices = new int[6];
this.university = null;
this.UniNumber = 0;
this.ChoiceNumber = 0;
this.StudyTrack = "";
this.studyAbroadAverage = 0.0;
this.studyAbroadChecked = false;
this.requirementsChecked = false;
this.masterApproval = new boolean[6];
this.firstName = firstName;
this.lastName = lastName;
this.prefix = prefix;
this.email1 = email1;
this.email2 = email2;
this.phoneNumber = phoneNumber;
}
// returns a student's ranking
public int getRanking() {
return this.Ranking;
}
// returns a student's ID number
public int getID() {
return this.StudentNumber;
}
// returns a student's university number
public int getUniNumber() {
return this.UniNumber;
}
// returns a student's 1st choice
public String getChoice(int i) {
return this.Choices[i-1];
}
// returns a student's ith choice
public int getNumberChoices(int i) {
return this.NumberChoices[i-1];
}
// returns a student's choice number
public int getChoiceNumber() {
return this.ChoiceNumber;
}
public String getPhoneNumber() {
return this.phoneNumber;
}
public String getFirstName() {
return this.firstName;
}
public String getLastName() {
return this.lastName;
}
public String getEmail1() {
return this.email1;
}
public String getEmail2() {
return this.email2;
}
public String getPrefix() {
return this.prefix;
}
// returns the university a student was assigned
public University getUni() {
return this.university;
}
// returns a student's allocated university
public String getUniName () {
return this.university.toString();
}
// returns a student's study track
public String getStudyTrack() {
return this.StudyTrack;
}
// returns a student's GPA
public double getStudyAbroadAverage() {
return this.studyAbroadAverage;
}
// returns if the requirements have been checked
public boolean allChecked() {
return (this.requirementsChecked && this.studyAbroadChecked);
}
// returns if a student's GPA was checked with regards to the university
public boolean getSAChecked() {
return this.studyAbroadChecked;
}
public boolean getOtherChecked() {
return this.requirementsChecked;
}
public int getApproved() {
int number = 0;
for (int i = 0; i<6; i++) {
if (this.masterApproval[i]) {
number = i;
}
}
return number;
}
// sets the student's choices as numbers
public void setNumberChoices (int[] array) {
this.NumberChoices = array;
}
// sets the student's study track
public void setStudy (String study) {
this.StudyTrack = study;
}
// sets the student's chosen uniNumber
public void setUniNumber (int uniNumber) {
this.UniNumber= uniNumber;
}
// sets the allocated university to the input
public void setUni (University university) {
this.university = university;
}
// sets the student's GPA
public void setStudyAbroadAverage (double number) {
this.studyAbroadAverage = number;
}
// sets the choice number to the input
public void setChoiceNumber (int number) {
this.ChoiceNumber = number;
}
public void setChoiceNumber(int choiceNumber, int uniNumber) {
this.NumberChoices[choiceNumber-1] = uniNumber;
}
// sets the person as having their requirements checked
public void setOtherChecked(boolean result) {
this.requirementsChecked = result;
}
// sets the student to having their GPA requirments checked
public void setStudyAbroadChecked(boolean result) {
this.studyAbroadChecked = result;
}
public void clearChoice (int choiceNumber) {
this.Choices[choiceNumber-1] = "";
this.NumberChoices[choiceNumber-1] = 0;
}
// Wipes the student's choice
public void studentWipe() {
int choice = this.getChoiceNumber();
System.out.println("Wiping" + this.Ranking + "'s " +
choice + "th choice.");
this.clearChoice(choice);
this.getUni().decrementAllocated();
}
// returns master approval
public boolean isMasterApproved(int number) {
if (number == 0) return true;
return this.masterApproval[number-1];
}
public void setApproval(int number) {
this.masterApproval[number-1] = true;
}
public String toString() {
return String.valueOf(this.StudentNumber);
}
/*
// return string representation of this student record
public String toString() {
if (this.ChoiceNumber!=0) {
return ("Student " + this.StudentNumber + ", studying " + this.StudyTrack + " was assigned to the following university: "
+ this.UniName + ". This was choice number " + this.ChoiceNumber + ".");
}
else {
return ("Student " + this.StudentNumber + " did not get assigned any universities. Please refer"
+ " to the list generated at the end of the program to see which universities they may "
+ "go to.");
}
}
*/
}