Question: Work programming exercise 13.13, page 531, Enable the Course class cloneable. Please follow the specifications given in the problem statement. Write a test program to

Work programming exercise 13.13, page 531, Enable the Course class cloneable. Please follow the specifications given in the problem statement. Write a test program to create at least 2 course objects, display the objects information, next clone each object, and finally display the cloned objects information.

13.13 (Enable the Course class cloneable) Rewrite the Course class in Listing 10.6 to add a clone method to perform a deep copy on the students field.

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

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!