forked from AndrewProgramming/JavaTutorialCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestCourse.java
More file actions
30 lines (22 loc) · 851 Bytes
/
TestCourse.java
File metadata and controls
30 lines (22 loc) · 851 Bytes
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
package objectandclass;
public class TestCourse {
public static void main(String[] args) {
Course course1 = new Course("Data structures");
Course course2 = new Course("Database systems");
course1.addStudent("Peter Jones");
course1.addStudent("Kim Smith");
course1.addStudent("Anne Ken");
course2.addStudent("Peter Jones");
course2.addStudent("Steve Smith");
System.out.println("Number of students in course1:" + course1.getNumberOfStudents());
String[] studentsInCourse1 = course1.getStudents();
for (int i = 0; i < course1.getNumberOfStudents(); i++) {
System.out.print(studentsInCourse1[i] + ",");
}
course1.dropStudent("Anne Ken");
System.out.println();
for (int i = 0; i < course1.getNumberOfStudents(); i++) {
System.out.print(studentsInCourse1[i] + ",");
}
}
}