-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathClassroom.java
More file actions
53 lines (47 loc) · 1.45 KB
/
Classroom.java
File metadata and controls
53 lines (47 loc) · 1.45 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
package io.zipcoder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class Classroom {
private Student[] student;
private Integer maxNumberOfStudents;
public Classroom(Integer maxNumberOfStudents){
this.student = new Student[maxNumberOfStudents];
}
public Classroom(Student[] student){
this.student = student;
}
public Classroom(){
this.student = new Student[30];
}
public Student[] getStudents() {
return student;
}
public Double getAverageExamScore(){
Double sumScore = 0.0;
for (Student thisStudent : student) {
sumScore += thisStudent.getAverageTestScores();
}
return sumScore/student.length;
}
public void addStudent(Student newStudent) {
for (int i = 0; i < student.length - 1; i++) {
if (student[i] == null) {
student[i] = newStudent;
}
}
}
public void removeStudent(String firstName, String lastName){
ArrayList<Student> newArrayList = new ArrayList<>(Arrays.asList(student));
for (int i = 0; i < student.length; i++) {
if(student[i].getFirstName().equals(firstName) && student[i].getLastName().equals(lastName)){
}
}
student = newArrayList.toArray(new Student[0]);
}
public void getStudentByScore(){
Arrays.sort(student);
}
public void getGradeBook(){
}
}