Question: Study the following classes: 1 . public class MyArrayList 2 . { 3 . private int size; / / Number of elements in the list

Study the following classes:
1. public class MyArrayList
2.{
3. private int size; // Number of elements in the list
4. private clubMember [] data;
5.
6./** Create an empty list */
7. public MyArrayList(){
8. data = new clubMember[10];
9. size =0;
10.}
11. public boolean sortList(){/*Assume code exist*/}
12.}
1. public class clubMember
2.{ private String name;
3. private String address;
4. private int handicap;
5. public clubMember (String n, String a, int num )
6.{ name = n;
7. address = a;
8. weight = num;
9.}
10. public void setName(String name)
11.{
12. this.name = name;
13.}
14.
15. public String toString()
16.{ return("Name is "+ name +
17." Address is: "+ address +
18." Handicap is: "+ weight +"
");
19.}
20.}
1. public class TestMyArrayList {
2. public static void main(String[] args){
3. MyArrayList< GymMember > list1= new MyArrayList< GymMember >();
4.
5. GymMember a = new GymMember ("Jan","Vleiloerie 7",5);
6. GymMember b = new GymMember ("Piet","Soetdoring 18",0);
7. GymMember c = new GymMember ("Bgani","Sefatsa st 5",15);
8.
9. list1.add(0,a);
10. list1.add(1,b);
11. list1.add(1,c);
12. list1.sortList()
13.
14. System.out.println(list1);
15.}
16.}
The given implementation class MyArraylist does NOT support generic objects. Write down the correct version of program lines of this class in to address this problem, then Write the Java code of the appropriate method for the clubMember class to enable it to be sorted in a
GENERIC MyArrayList class. Assume that members are compared according to their handicap. and the Java code for the remove method in the MyArrayList classs.

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!