-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCourse.java
More file actions
51 lines (45 loc) · 1.52 KB
/
Course.java
File metadata and controls
51 lines (45 loc) · 1.52 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
public class Course {
private String courseCode;
private String title;
private String description;
private int capacity;
private String schedule;
private int enrolledStudents;
public Course(String courseCode, String title, String description, int capacity, String schedule) {
this.courseCode = courseCode;
this.title = title;
this.description = description;
this.capacity = capacity;
this.schedule = schedule;
this.enrolledStudents = 0;
}
// Getters and Setters
public String getCourseCode() { return courseCode; }
public String getTitle() { return title; }
public String getDescription() { return description; }
public int getCapacity() { return capacity; }
public String getSchedule() { return schedule; }
public int getEnrolledStudents() { return enrolledStudents; }
public boolean isFull() {
return enrolledStudents >= capacity;
}
public boolean enrollStudent() {
if (!isFull()) {
enrolledStudents++;
return true;
}
return false;
}
public boolean dropStudent() {
if (enrolledStudents > 0) {
enrolledStudents--;
return true;
}
return false;
}
@Override
public String toString() {
return "Course Code: " + courseCode + ", Title: " + title + ", Description: " + description +
", Capacity: " + capacity + ", Schedule: " + schedule + ", Enrolled: " + enrolledStudents;
}
}