-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStudent.java
270 lines (257 loc) · 8.7 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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
import java.util.*;
import javafx.scene.control.Alert.AlertType;
public class Student{
private String name;
private String Last_Name;
private Long Studentid;
private int Number_Of_Courses_Assigned;
private int Number_Of_Units_Assigned;
private List<Course> Courses_Assigned = new ArrayList<Course>();
private List<Teacher> listOfTeachers = new ArrayList<Teacher>();
private List<Term> terms = new ArrayList<Term>();
private List<SCORE> Ongoing_Term_scores = new ArrayList<SCORE>();
private int Number_Of_Terms = 0;
private String Email ;
private String birthdate ;
private List<Assignment> projects = new ArrayList<Assignment>();
Student(String name, String Last_Name, Long Studentid , String Email , String birthdate){
this.name =name;
this.Last_Name = Last_Name;
this.Studentid = Studentid;
this.Email = Email;
this.birthdate = birthdate;
}
public String getBirthdate() {
return birthdate;
}
public void addProjects(Assignment a){
projects.add(a);
}
public void removeProject(Assignment a){
projects.remove(a);
}
public List<Assignment> getProjects(){
return projects;
}
public double MaxScore(){
double maxscore=0.0;
for(int i = 0 ; i< Ongoing_Term_scores.size();i++){
if(Ongoing_Term_scores.get(i).getScore()>maxscore){
maxscore = Ongoing_Term_scores.get(i).getScore();
}
}
return maxscore;
}
public double MinScore(){
double minscore=20.0;
for(int i = 0 ; i< Ongoing_Term_scores.size();i++){
if(Ongoing_Term_scores.get(i).getScore()<minscore){
minscore = Ongoing_Term_scores.get(i).getScore();
}
}
return minscore;
}
public double CurrentTermAverage(){
double average = 0.0;
int i = 0;
for( ; i< Ongoing_Term_scores.size();i++){
average+=Ongoing_Term_scores.get(i).getScore();
}
average = average/i;
return average;
}
public double TermAverage(int TermNumber){
List<SCORE> SCORES = terms.get(TermNumber-1).getScores();
double average = 0.0;
int i = 0;
for( ; i< SCORES.size();i++){
average+=SCORES.get(i).getScore();
}
average = average/i;
return average;
}
public void setEmail(String email) {
Email = email;
}
public String getEmail() {
return Email;
}
public Long getSID(){
return Studentid;
}
public void setNumber_Of_Courses_Assigned(int Number_Of_Courses_Assigned) {
this.Number_Of_Courses_Assigned = Number_Of_Courses_Assigned;
}
public void setLast_Name(String Last_Name){
this.Last_Name = Last_Name;
}
public int getNumber_Of_Courses_Assigned() {
return Number_Of_Courses_Assigned;
}
public void addTerms(){
Number_Of_Terms ++;
Term newterm = new Term();
terms.add(newterm);
}
public void addCourse(Course course , Teacher teacher ){
Ongoing_Term_scores = terms.get(Number_Of_Terms-1).getScores();
Courses_Assigned = terms.get(Number_Of_Terms-1).getCourses_Assigned();
listOfTeachers = terms.get(Number_Of_Terms-1).getListOfTeachers();
teacher.addStudent(this , course);
listOfTeachers.add(teacher);
Courses_Assigned.add(course);
Number_Of_Units_Assigned += course.getUnitsPerCourse();
course.AddStudents(this);
Number_Of_Courses_Assigned++;
SCORE score = new SCORE(course,teacher.getTeacherid(),Number_Of_Terms);
Ongoing_Term_scores.add(score);
terms.get(Number_Of_Terms-1).setCourses_Assigned(Courses_Assigned);
terms.get(Number_Of_Terms-1).setListOfTeachers(listOfTeachers);
terms.get(Number_Of_Terms-1).setScores(Ongoing_Term_scores);
}
public void removeCourse(Course course , Teacher teacher){
Ongoing_Term_scores = terms.get(Number_Of_Terms-1).getScores();
Courses_Assigned = terms.get(Number_Of_Terms-1).getCourses_Assigned();
listOfTeachers = terms.get(Number_Of_Terms-1).getListOfTeachers();
course.RemoveStudents(this);
if(teacher.getStudentsOfTeacher().contains(this)){
teacher.removeStudent(this , course);
}
Number_Of_Courses_Assigned--;
Courses_Assigned.remove(course);
listOfTeachers.remove(teacher);
terms.get(Number_Of_Terms-1).setCourses_Assigned(Courses_Assigned);
terms.get(Number_Of_Terms-1).setListOfTeachers(listOfTeachers);
terms.get(Number_Of_Terms-1).setScores(Ongoing_Term_scores);
}
public ALPHABETSCORE GetAlphabeticalscore(Term term){
double average = calculateAverageTermScore(term);
if(average>=17){
return ALPHABETSCORE.A;
}
else if(average >= 14){
return ALPHABETSCORE.B ;
}
else if(average > 10){
return ALPHABETSCORE.C;
}
else if(average > 7){
return ALPHABETSCORE.D;
}
else if(average>4){
return ALPHABETSCORE.E;
}
return ALPHABETSCORE.F;
}
public void setNumber_Of_Units_Assigned(int Number_Of_Units_Assigned) {
this.Number_Of_Units_Assigned = Number_Of_Units_Assigned;
}
public int getNumber_Of_Units_Assigned() {
return Number_Of_Units_Assigned;
}
public void setCourses_Assigned(List<Course> Courses_Assigned) {
this.Courses_Assigned = Courses_Assigned;
}
public void setName(String name){
this.name = name;
}
public String getName(){
return name;
}
public List<Course> getCourses_Assigned() {
return Courses_Assigned;
}
public String getLast_Name(){
return Last_Name;
}
public void AddCourse(Course New){
Courses_Assigned.add(New);
}
public String givescore(Course course , Teacher teacher , double score){
Ongoing_Term_scores = terms.get(Number_Of_Terms-1).getScores();
for(int i = 0 ; i <Ongoing_Term_scores.size() ;i++){
if(Ongoing_Term_scores.get(i).getCourse().equals(course)){
if(teacher.getTeacherid()==Ongoing_Term_scores.get(i).getTeacherid()){
Ongoing_Term_scores.get(i).setScore(score);
return "DONE !";
}
}
}
return "ERROR";
}
public int getNumber_Of_Terms() {
return Number_Of_Terms;
}
public double calculateAverageTermScore(Term term){
List<SCORE> listofScores = term.getScores();
int numberofunits = 0 ;
double sumofscores = 0.0;
for(int i = 0 ; i <listofScores.size() ; i++){
numberofunits += listofScores.get(i).getCourse().getUnitsPerCourse();
sumofscores+= (listofScores.get(i).getCourse().getUnitsPerCourse()*listofScores.get(i).getScore());
}
sumofscores = sumofscores/numberofunits;
return sumofscores;
}
public List<Term> getTerms() {
return terms;
}
}
enum ALPHABETSCORE {
A,
B,
C,
D,
E,
F
}
class SCORE{
Course course;
long teacherid;
int term ;
double score;
SCORE(Course course , long teacherid , int term){
this.course = course;
this.teacherid = teacherid;
this.term = term;
}
public Course getCourse() {
return course;
}
public double getScore() {
return score;
}
public long getTeacherid() {
return teacherid;
}
public int getTerm() {
return term;
}
public void setScore(double score) {
this.score = score;
}
}
class Term{
private List<SCORE> scores = new ArrayList<SCORE>();
private List<Course> Courses_Assigned = new ArrayList<Course>();
private List<Teacher> listOfTeachers = new ArrayList<Teacher>();
Term(){}
public void setScores(List<SCORE> scores) {
this.scores = scores;
}
public void setListOfTeachers(List<Teacher> listOfTeachers) {
this.listOfTeachers = listOfTeachers;
}
public void setCourses_Assigned(List<Course> courses_Assigned) {
Courses_Assigned = courses_Assigned;
}
public List<SCORE> getScores() {
return scores;
}
public List<Course> getCourses_Assigned() {
return Courses_Assigned;
}
public List<Teacher> getListOfTeachers() {
return listOfTeachers;
}
}