-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathClassroomTest.java
More file actions
146 lines (119 loc) · 5.32 KB
/
ClassroomTest.java
File metadata and controls
146 lines (119 loc) · 5.32 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
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
package io.zipcoder;
import org.junit.Assert;
import org.junit.Test;
import java.util.Arrays;
public class ClassroomTest {
@Test
public void getStudentsTest () {
// : Given
Double[] s1Scores = { 100.0, 150.0 };
Double[] s2Scores = { 225.0, 25.0 };
Student s1 = new Student("", "student", "one", s1Scores);
Student s2 = new Student("", "student", "two", s2Scores);
Student[] students = {s1,s2};
Classroom classroom = new Classroom(students);
// When
String output = String.valueOf(classroom.getStudents());
// Then
System.out.println(output);
}
@Test
public void getAverageExamScoreTest () { // needs some work
Double[] s1Scores = { 100.0, 150.0 };
Double[] s2Scores = { 275.0, 25.0 };
Student s1 = new Student("", "student", "one", s1Scores);
Student s2 = new Student("", "student", "two", s2Scores);
Student[] student = {s1,s2};
Classroom classroom = new Classroom(student);
// When
double output = classroom.getAverageExamScore();
// Then
System.out.println(output);
}
@Test
public void addStudentTest () {
// : Given
int maxNumberOfStudents = 1;
Classroom classroom = new Classroom(maxNumberOfStudents);
Double[] examScores = { 100.0, 150.0, 250.0, 0.0 };
Student student = new Student("", "Leon", "Hunter", examScores);
// When
Student[] preEnrollment = classroom.getStudents();
classroom.addStudent(student);
Student[] postEnrollment = classroom.getStudents();
// Then
String preEnrollmentAsString = Arrays.toString(preEnrollment);
String postEnrollmentAsString = Arrays.toString(postEnrollment);
System.out.println("===========================");
System.out.println(preEnrollmentAsString);
System.out.println("===========================");
System.out.println(postEnrollmentAsString);
}
@Test
public void removeStudentTest () {
// : Given
int maxNumberOfStudents = 1;
Classroom classroom = new Classroom(maxNumberOfStudents);
Double[] examScores = { 100.0, 150.0, 250.0, 0.0 };
Student student = new Student("", "Leon", "Hunter", examScores);
// When
classroom.addStudent(student);
Student[] postEnrollment = classroom.getStudents();
classroom.removeStudent("Leon", "Hunter");
Student[] afterRemoval = classroom.getStudents();
// Then
String afterRemovalThing = Arrays.toString(afterRemoval);
String postEnrollmentAsString = Arrays.toString(postEnrollment);
System.out.println(postEnrollmentAsString);
System.out.println(afterRemovalThing);
}
@Test
public void sortingByScoreTest () {
// "Cannot find local variable 'classroom' " from debugger with break on 92
Double[] examScores = {100.0, 150.0, 250.0, 0.0};
Double[] examScores1 = {50.0, 75.0 , 125.0, 0.0};
Double[] examScores2 = {200.0, 300.0 , 400.0, 50.0};
Double[] examScores3 = {50.0, 75.0 , 125.0, 0.0};
Double[] examScores4 = {0.0, 0.0};
Double[] examScores5 = {1000.0};
Student s = new Student("", "Leon", "Hunter", examScores);
Student s1 = new Student("", "Eric", "Weenermier", examScores1);
Student s2 = new Student("", "Kyle", "Calzone", examScores2);
Student s3 = new Student("", "Cal", "Weenermier", examScores3);
Student s4 = new Student("", "Ryan", "Coffee", examScores4);
Student s5 = new Student("", "Front", "Runner", examScores5);
// When
Student[] student = {s, s1, s2, s3};
Classroom classroom69 = new Classroom(student);
Student[] postEnrollment = classroom69.getStudents();
classroom69.getStudentsByScore();
Student[] afterSorting = classroom69.getStudents();
// Then
String postEnrollmentAsString = Arrays.toString(postEnrollment);
System.out.println(postEnrollmentAsString);
System.out.println(Arrays.toString(afterSorting));
}
@Test
public void getGradeBookTest () { // avg
// Given
Double[] examScores = {100.0, 150.0, 250.0, 0.0}; // 125.0
Double[] examScores1 = {50.0, 75.0 , 125.0, 0.0}; // 62.5
Double[] examScores2 = {200.0, 300.0 , 400.0, 50.0}; // 237.5
Double[] examScores3 = {50.0, 75.0 , 125.0, 0.0}; // 62.5
Double[] examScores4 = {0.0, 0.0}; // 0.0
Double[] examScores5 = {1000.0}; // 1000.0
Student s = new Student("", "Leon", "Hunter", examScores);
Student s1 = new Student("", "Eric", "Weenermier", examScores1);
Student s2 = new Student("", "Kyle", "Calzone", examScores2);
Student s3 = new Student("", "Cal", "Weenermier", examScores3);
Student s4 = new Student("", "Ryan", "Coffee", examScores4);
Student s5 = new Student("", "Front", "Runner", examScores5);
Student[] student = {s, s1, s2, s3, s4, s5};
// When
Classroom classroom69 = new Classroom(student);
Student[] actual = classroom69.getGradeBook();
Student[] expected = {s5, s2, s, s1, s3, s4};
// Then
Assert.assertEquals(expected, actual);
}
}