Problem

(Enable the Courseclass cloneable) Rewrite the Course class in Listing 1 to add a clone me...

(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 }

Step-by-Step Solution

Request Professional Solution

Request Solution!

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.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT