-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathStudent.java
More file actions
102 lines (88 loc) · 2.7 KB
/
Student.java
File metadata and controls
102 lines (88 loc) · 2.7 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
package students;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public final class Student {
private String name;
private float gpa;
private List<String> courses;
private Student(String name, float gpa, List<String> courses) {
if (name == null || gpa < 0 || gpa > 4) throw new IllegalArgumentException("Bad values...");
this.name = name;
this.gpa = gpa;
this.courses = courses;
}
public static Student ofNameGpaCourses(String name, float gpa, String ... courses) {
// return new Student(name, gpa, Arrays.asList(courses.clone()));
return new Student(name, gpa, Arrays.asList(courses));
}
public String getName() {
return name;
}
public float getGpa() {
return gpa;
}
public List<String> getCourses() {
return Collections.unmodifiableList(courses);
}
@Override
public String toString() {
return "Student{" +
"name='" + name + '\'' +
", gpa=" + gpa +
", courses=" + courses +
'}';
}
public static StudentCriterion getSmartnessCriterion(float threshold) {
float [] vals = { threshold };
// threshold ++;
System.out.println("CREATING TEST!!!");
return s -> {
System.out.println("EXECUTING TEST!!!");
vals[0]++;
return s.gpa > vals[0];
};
}
// static class SmartnessCriterion implements StudentCriterion {
// @Override
// public boolean test(Student s) {
// return s.getGpa() > 3.0F;
// }
// }
//
private static final StudentCriterion enthusiasmCriterion =
s -> s.getCourses().size() > 3 ;
// private static final StudentCriterion enthusiasmCriterion =
// /*(Student*/ s/*)*/ -> /*{ return*/ s.getCourses().size() > 3/*; }*/;
//
// private static final StudentCriterion enthusiasmCriterion =
// (Student s) -> { return s.getCourses().size() > 3; };
//
// private static final StudentCriterion enthusiasmCriterion = /*new StudentCriterion() {*/
//// @Override
// /*public boolean test*/ (Student s) -> {
// return s.getCourses().size() > 3;
// }
// /*}*/;
//
// private static final StudentCriterion enthusiasmCriterion = new /*EnthusiasmCriterion();
//
// private static class EnthusiasmCriterion implements */ StudentCriterion() {
// @Override
// public boolean test(Student s) {
// return s.getCourses().size() > 3;
// }
// };
// private static final StudentCriterion enthusiasmCriterion = new EnthusiasmCriterion();
//
// private static class EnthusiasmCriterion implements StudentCriterion {
// @Override
// public boolean test(Student s) {
// return s.getCourses().size() > 3;
// }
// }
//
public static StudentCriterion getEnthusiasmCriterion() {
return enthusiasmCriterion;
}
}