-
Notifications
You must be signed in to change notification settings - Fork 2
/
Course.java
48 lines (39 loc) · 1.25 KB
/
Course.java
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
import java.io.Serializable;
public class Course implements Serializable {
private String name;
private pavan_dynamic_array teachers;
private pavan_dynamic_array students;
public Course(String name) {
this.name = name;
teachers = new pavan_dynamic_array(1);
students = new pavan_dynamic_array(1);
}
public String getName() {
return name;
}
public pavan_dynamic_array getTeachers() {
return teachers;
}
public pavan_dynamic_array getStudents() {
return students;
}
public void addTeacher(Teacher teacher) {
teachers.add(teacher);
}
public void addStudent(Student student) {
students.add(student);
}
public void displayCourseInfo() {
System.out.println("Course Name: " + name);
System.out.println("Teachers: ");
for (int i = 0; i < teachers.size(); i++) {
Teacher teacher = (Teacher) teachers.get(i);
System.out.println("- " + teacher.getName());
}
System.out.println("Enrolled Students: ");
for (int i = 0; i < students.size(); i++) {
Student student = (Student) students.get(i);
System.out.println("- " + student.getName());
}
}
}