Question: Revise the Course class as follows:? The array size is fixed in Listing 10.6. Improve it to automatically increase the array size by creating a
Revise the Course class as follows:? The array size is fixed in Listing 10.6. 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 public class Course { private String courseName; private String[] students =](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2022/11/636a72d7f23c6_599636a72d7e20af.jpg)
1 public class Course { private String courseName; private String[] students = new String[100]; private int number0fStudents; 2 3 4 public Course(String courseName) { this.courseName = courseName; public void addStudent (String student) { students[numberOfStudents] = student; numberofStudents++; 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 } public String[] getStudents () { return students; public int getNumberOfStudents() { return number0fStudents; public String getCourseName () { return courseName; public void dropStudent(String student) { // Left as an exercise in Programming Exercise 10.9
Step by Step Solution
3.33 Rating (174 Votes )
There are 3 Steps involved in it
Program Plan Define the class Course o Define the method addStudents Check the size of the array and ... View full answer
Get step-by-step solutions from verified subject matter experts
