Please write missing statements to make the following method buildMap complete. The buildMap method takes a book array s as the parameter and returns a HashMap instance that consists of a collection of pairs of the key ISBN coupling up with its corresponding book object. public HashMap buildMap(Book[] s) { I/TODO Write the statements here
Please write missing statements to make the following method buildMap complete. The buildMap method takes a book array s as the parameter and returns a HashMap instance that consists of a collection of pairs of the key ISBN coupling up with its corresponding book object. public HashMap buildMap(Book[] s) { I/TODO Write the statements here
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
BooksMan
import java.util.HashMap;
import java.util.ArrayList;
class Book{
String title, ISBN;
ArrayList authors;
public Book (String title, String ISBN, String authors){
this.title = title;
this.ISBN = ISBN;
this.authors = new ArrayList();
if (authors != null) {
String [] authorArray = authors.split(", ");
for (int i = 0; i < authorArray.length; i++) {
this.authors.add(authorArray[i]);
}
}
}
public String getISBN() {
return ISBN;
}
public String getTitle() {
return title;
}
public ArrayList getAuthors() {
return authors;
}
}
public class Main {
public static HashMap buildMap(Book[] s) {
HashMap books = new HashMap();
if (s != null) {
// TODO Write the statements here: to manage each book from the parameter array reference to the hashmap
}
return books;
}
public static void main(String argv[]) {
Book[] bookArray = new Book[4];
for (int i = 0; i < 4; i++) {
bookArray[i] = new Book((new Integer(i)).toString(), (new Integer(i)).toString(), "ITSC2214" );
}
HashMap books = Main.buildMap(bookArray);
System.out.println("The total number of books is " + books.size());
for (int i = 0; i < 4; i++) {
System.out.println("Book[" + i + "] is " + books.get((new Integer(i)).toString()).getTitle());
}
}
}
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY