Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Select Healthcare Classification Systems And Databases

Authors: Katherine S. Rowell, Ann Cutrell

1st Edition

0615909760, 978-0615909769

More Books

Students also viewed these Databases questions