-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathClassroomTest.java
More file actions
127 lines (97 loc) · 4.15 KB
/
ClassroomTest.java
File metadata and controls
127 lines (97 loc) · 4.15 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
package io.zipcoder;
import org.junit.Assert;
import org.junit.Test;
import java.util.Arrays;
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.getClassAverageExamScore();
// Then
Assert.assertEquals(output,classroom.getClassAverageExamScore(), 0.00);
}
@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.getStudentArray();
classroom.addStudent(student);
Student[] postEnrollment = classroom.getStudentArray();
// 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 getStudentsByScoreTest() {
// Given // What do i need to make
String givenFirstName1 = "Leon";
String givenLastName1 = "Hunter";
Double[] examScores1 = {100.0, 95.0, 123.0, 96.0};
Student student1 = new Student(givenFirstName1, givenLastName1, examScores1);
String givenFirstName2 = "Leon";
String givenLastName2 = "Gamer";
Double[] examScores2 = {100.0, 95.0, 123.0, 96.0};
Student student2 = new Student(givenFirstName2, givenLastName2, examScores2);
String givenFirstName3 = "Sammy";
String givenLastName3 = "Sheen";
Double[] examScores3 = {98.0, 95.0, 103.0, 90.0};
Student student3 = new Student(givenFirstName3, givenLastName3, examScores3);
Classroom classroom = new Classroom(student1, student2, student3);
Student[] expected = {student2, student1, student3};
// When // Getting the actual
Student[] actual = classroom.getStudentsByScore();
// Then // Test expected against actual
Assert.assertArrayEquals(expected, actual);
}
@Test
public void removeStudentTest() {
// Given
Double[] examScores1 = {85.0, 90.0, 95.0};
Double[] examScores2 = {88.0, 90.0, 100.0};
Double[] examScores3 = {80.0, 97.0, 85.0};
Student student1 = new Student("Frank", "Kelp", examScores1);
Student student2 = new Student("Sarah", "Blanco", examScores2);
Student student3 = new Student("James", "Bond", examScores3);
Student[] students = {student1, student2, student3};
// When
Classroom testRoom = new Classroom();
testRoom.addStudent(student1);
testRoom.addStudent(student2);
testRoom.addStudent(student3);
testRoom.removeStudent("James", "Bond");
// Then
System.out.println((Arrays.toString(testRoom.getStudentArray())));
Student actual = testRoom.getStudentArray()[2];
Assert.assertNull(actual);
}
@Test
public void getGradeBookTest() {
// Given
Double[] examScores1 = {85.0, 90.0, 95.0};
Double[] examScores2 = {88.0, 90.0, 90.0};
Double[] examScores3 = {80.0, 97.0, 85.0};
Student student1 = new Student("Frank", "Kelp", examScores1);
Student student2 = new Student("Sarah", "Blanco", examScores2);
Student student3 = new Student("James", "Bond", examScores3);
Student[] students = {student1, student2, student3};
// When
Classroom testRoom = new Classroom(student1,student2, student3);
// Then
System.out.println(testRoom.getGradeBook());
}
}