-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCourseDetail.java
More file actions
37 lines (32 loc) · 1.11 KB
/
CourseDetail.java
File metadata and controls
37 lines (32 loc) · 1.11 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
public class CourseDetail {
String courseName;
int enrollments;
static int maxCapacity=10;
String[] enrolledstudents ;
CourseDetail(String courseName){
this.courseName=courseName;
this.enrollments=0;
this.enrolledstudents=new String[maxCapacity];
}
static void setMaxCapacity(int maxCapacity){
CourseDetail.maxCapacity = maxCapacity;
}
void enrollStudent(String studentName){
enrolledstudents[enrollments] = studentName;
System.out.println("Congratulation Name as :- "+studentName);
enrollments++;
}
void unenrollstudent(String studentName){
System.out.println("Student removed");
enrollments--;
}
public static void main(String[] args) {
CourseDetail obj=new CourseDetail("java core");
obj.enrollStudent("Aditya kumar");
obj.enrollStudent("Rishu kumar");
obj.enrollStudent("Rohit kumar");
obj.enrollStudent("Shushant kumar");
obj.enrollStudent("Mohit kumar");
obj.unenrollstudent("Mohit kumar");
}
}