-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathClassroomTest.java
More file actions
94 lines (71 loc) · 3.32 KB
/
ClassroomTest.java
File metadata and controls
94 lines (71 loc) · 3.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
package io.zipcoder;
import org.junit.Assert;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
public class ClassroomTest {
@Test
public void testGetAvergeExamScore() {
ArrayList<Double> s1Scores = new ArrayList<Double>(Arrays.asList(84.00, 92.00));
ArrayList<Double> s2Scores = new ArrayList<Double>(Arrays.asList(96.0, 100.00));
Student s1 = new Student("Kai", "Shields", s1Scores);
Student s2 = new Student("Kendra", "Ng", s2Scores);
Double expectedAverage = 93.0;
Student[] students = {s1, s2};
Classroom classroom = new Classroom(students);
Double actual = classroom.getAverageExamScore();
Assert.assertEquals(expectedAverage, actual);
}
@Test
public void testAddStudent() {
int maxNumberOfStudents = 1;
Classroom classroom = new Classroom(maxNumberOfStudents);
ArrayList<Double> examScores = new ArrayList<>(Arrays.asList(100.0, 85.0, 76.0, 0.0));
Student student = new Student("Kai", "Shields", examScores);
Student[] preEnrollment = classroom.getStudents();
classroom.addStudent(student);
Student[] postEnrollment = classroom.getStudents();
String preEnrollmentAsString = Arrays.toString(preEnrollment);
String postEnrollmentAsString = Arrays.toString(postEnrollment);
}
@Test
public void testRemoveStudent() {
Integer maxNumberOfStudents = 1;
Classroom classroom = new Classroom(maxNumberOfStudents);
ArrayList<Double> s2Scores = new ArrayList<>(Arrays.asList(89.0, 100.0, 50.0));
Student s1 = new Student("Kai", "Shields", s2Scores);
classroom.addStudent(s1);
Integer actual = classroom.getStudents().length;
classroom.removeStudent("Kai", "Shields");
Assert.assertEquals(maxNumberOfStudents, actual);
}
@Test
public void testGetStudentsByScore() {
ArrayList<Double> s1Scores = new ArrayList<Double>(Arrays.asList(100.0, 93.0));
ArrayList<Double> s2Scores = new ArrayList<Double>(Arrays.asList(78.0, 85.0));
Student s1 = new Student("Kendra", "Ng", s2Scores);
Student s2 = new Student("Kai", "Shields", s1Scores);
Student[] students = {s1, s2};
Classroom classroom = new Classroom(students);
classroom.addStudent(s1);
classroom.addStudent(s2);
Student[] preEnrollment = classroom.getStudents();
String preEnrollmentAsString = Arrays.toString(preEnrollment);
classroom.getStudentsByScore();
Student[] postEnrollment = classroom.getStudents();
String postEnrollmentAsString = Arrays.toString(postEnrollment);
}
@Test
public void testGetGradeBook() {
ArrayList<Double> s1Scores = new ArrayList<Double>(Arrays.asList(70.0, 100.0));
ArrayList<Double> s2Scores = new ArrayList<Double>(Arrays.asList(94.0, 85.0));
ArrayList<Double> s3Scores = new ArrayList<Double>(Arrays.asList(62.0, 96.0));
Student s1 = new Student("Kai", "Shields", s1Scores);
Student s2 = new Student("Kendra", "Ng", s2Scores);
Student s3 = new Student("Val", "Fraiger", s3Scores);
Student[] students = {s1, s2, s3};
Classroom classroom = new Classroom(students);
Map gradeBook = classroom.getGradeBook();
}
}