Question: for drjava please The attached java class uses an array for holding a collection of book names. Please modify this class replacing the books array

for drjava please

The attached java class uses an array for holding a collection of book names. Please modify this class replacing the books array with an ArrayList using the same name books. The list array in the main method does not need to change, it's strictly used for assigning names of books to the 2 members.

My advice would be to download the file, compile it and run it to see the output it generates. After you've replaced the array with an ArrayList the output generated should be the same.

Attached file

public class Member{ private int id; private String name; private String[] books = new String[5]; //replace the String books array with an ArrayList variable named books //that functions exactly the same way public Member() { id = 0; name = "John Doe"; } public Member(int pId, String pName) { id = pId; name = pName; } public int getId(){ return id; } public void setId(int pId){ id=pId; } public String getName(){ return name; } public void setName(String pName){ name=pName; } public String[] getBooks(){ return books; } public void setBooks(String[] pBooks){ books=pBooks; } public String toString(){ StringBuffer buf = new StringBuffer(); buf.append("ID: " + getId() + " Member: " + getName() + " "); for(int x=0; x                                            

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!