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 =

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

1 Expert Approved Answer
Step: 1 Unlock

Program Plan Define the class Course o Define the method addStudents Check the size of the array and ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Java Programming Questions!