Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started