(The Course class) Revise the Course class as follows:
■ The array size is fixed in Listing 1. Improve it to automatically increase the array size by creating a new larger array and copying the contents of the current array to it.
■ Implement the dropStudent method.
■ Add a new method named clear() that removes all students from the course.
Write a test program that creates a course, adds three students, removes one, and displays the students in the course.
LISTING 1 Course.java
1 public class Course {
2 private String courseName;
3 private String[] students = new String[100];
4 private int numberOfStudents;
5
6 public Course(String courseName) {
7 this.courseName = courseName;
8 }
9
10 public void addStudent(String student) {
11 students[numberOfStudents] = student;
12 numberOfStudents++;
13 }
14
15 public String[] getStudents() {
16 return students;
17 }
18
19 public int getNumberOfStudents() {
20 return numberOfStudents;
21 }
22
23 public String getCourseName() {
24 return courseName;
25 }
26
27 public void dropStudent(String student) {
28 // Left as an exercise in Programming Exercise 10.9
29 }
30 }
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.