-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathClassroomTest.java
More file actions
106 lines (83 loc) · 3.51 KB
/
ClassroomTest.java
File metadata and controls
106 lines (83 loc) · 3.51 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
package io.zipcoder;
import org.junit.Assert;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.TreeMap;
import static org.junit.Assert.*;
public class ClassroomTest {
@Test
public void getAverageExamScoreTest(){
// : 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
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();
String preEnrollmentAsString = Arrays.toString(preEnrollment);
System.out.println("===========================");
System.out.println(preEnrollmentAsString);
classroom.addStudent(student);
Student[] postEnrollment = classroom.getStudents();
String postEnrollmentAsString = Arrays.toString(postEnrollment);
System.out.println("===========================");
System.out.println(postEnrollmentAsString);
}
@Test
public void removeStudentTest() {
// : Given
int maxNumberOfStudents = 2;
Classroom classroom = new Classroom(maxNumberOfStudents);
Double[] examScores = {100.0, 150.0, 250.0, 0.0};
Student student = new Student("Leon", "Hunter", examScores);
Double[] examScores2 = {100.0, 150.0, 250.0, 0.0};
Student student2 = new Student("Lilian", "Smith", examScores2);
classroom.addStudent(student);
classroom.addStudent(student2);
// When
Student[] preRemovingStudent = classroom.getStudents();
String preRemovingAsString = Arrays.toString(preRemovingStudent);
System.out.println("===========================");
System.out.println(preRemovingAsString);
classroom.removeStudent("Leon", "Hunter");
Student[] afterRemoving = classroom.getStudents();
String afterRemovigAsString = Arrays.toString(afterRemoving);
System.out.println("===========================");
System.out.println(afterRemovigAsString);
}
@Test
public void getStudentByScoreTest(){
int maxNumberOfStudents = 4;
Classroom classroom = new Classroom(maxNumberOfStudents);
Double[] examScoresS1 = {92.0, 150.0, 250.0, 50.0};
Double[] examScoresS2 = {250.0, 100.0, 100.0, 100.0};
Double[] examScoresS3 = {92.0, 150.0, 250.0, 50.00};
Double[] examScoresS4 = {90.0, 120.0, 99.0, 100.0};
// When
Student testS1 = new Student("Leon", "Hunter", examScoresS1);
Student testS2 = new Student("Joe", "Smith", examScoresS2);
Student testS3 = new Student("Mike", "Jones", examScoresS3);
Student testS4 = new Student("Bob", "Johnson", examScoresS4);
classroom.addStudent(testS1);
classroom.addStudent(testS2);
classroom.addStudent(testS3);
classroom.addStudent(testS4);
System.out.println(classroom.getStudentByScore(100.0).toString());
}
}