-
Notifications
You must be signed in to change notification settings - Fork 0
/
Course.java
126 lines (93 loc) · 2.96 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
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
package LAB.Sixth;
import java.util.ArrayList;
public class Course {
private String courseId;
private String courseTitle;
private double credit;
//private Student[] studentList;
private ArrayList<Student> studentList;
private int numberOfStudent;
private Faculty faculty;
public Course() {
//this.faculty = null;
this.studentList = new ArrayList<Student>();
}
public Course(String courseId, String courseTitle, double credit) {
this.courseId = courseId;
this.courseTitle = courseTitle;
this.credit = credit;
//this.faculty = null;
this.studentList = new ArrayList<Student>();
}
public String getCourseId() {
return courseId;
}
public void setCourseId(String courseId) {
this.courseId = courseId;
}
public String getCourseTitle() {
return courseTitle;
}
public void setCourseTitle(String courseTitle) {
this.courseTitle = courseTitle;
}
public double getCredit() {
return credit;
}
public void setCredit(double credit) {
this.credit = credit;
}
public ArrayList<Student> getStudentList() {
return studentList;
}
public void setStudentList(ArrayList<Student> studentList) {
this.studentList = studentList;
}
public int getNumberOfStudent() {
return numberOfStudent;
}
// public void setNumberOfStudent(int numberOfStudent) {
// this.numberOfStudent = numberOfStudent;
// }
public Faculty getFaculty() {
return faculty;
}
public void setFaculty(Faculty faculty) {
this.faculty = faculty;
}
@Override
public String toString() {
return "\n Course ID : " + courseId +
" || Course Title : " + courseTitle +
" || Credit : " + credit +
" || Number Of Student : " + numberOfStudent +
"\n Faculty Info : " + faculty + "\n";
}
public void addStudent(Student student) {
this.studentList.add(student);
this.numberOfStudent++;
}
public void dropStudent(int studentId) {
for (Student student : studentList) {
if (student.getStudentId()==studentId) {
studentList.remove(student);
this.numberOfStudent--;
}
}
}
public void addFaculty(Faculty faculty) {
this.faculty = faculty;
}
public void dropFaculty() {
this.faculty = null;
}
public String printStudentList() {
String msg = "";
for (Student s : studentList) {
msg += "\n [Student ID : " + s.getStudentId() +
" || Student Name : " + s.getStudentName() +
" || Student CGPA : " + s.getStudentCGPA() + "]";
}
return msg;
}
}