(Enable the Courseclass cloneable) Rewrite the Course class in Listing 1 to add a clone method to perform a deep copy on the students field.
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.