Question: public class book { public String name,author; int year; public book ( String namei,String authori,int yeari ) { name = namei;author = authori;year = yeari;
public class book
public String name,author;
int year;
public bookString namei,String authori,int yeari
namenamei;authorauthori;yearyeari;
public bookbook bi
namebiname;authorbiauthor;yearbiyear;
public String toString
String s"book name name book author author publication year year
;
return s;
import java.util.;
public class library
String name;
int numberofbooks;
TreeMap bookname new TreeMap;
TreeMap authorname new TreeMap;
public libraryString kname
namekname;
numberofbooks;
public void addbook b
bookname.putbname,b;
authorname.putbauthor,b;
numberofbooksbookname.size;
public void removebook b
numberofbooks;
bookname.removebname;
authorname.removebauthor;
numberofbooksbookname.size;
public String listwithname
String sbookname.valuestoString;
return s;
public String listwithauthor
String sauthorname.valuestoString;
return s;
public String getwithnameString name
String sbookname.getnametoString;
return s;
public String toStringwithname
String s"Library name : name
;
s"Total number of books : numberofbooks
;
slistwithname
;
return s;
public String toStringwithauthor
String s"Library name : name
;
s"Total number of books : numberofbooks
;
slistwithauthor;
return s;
Add books to the library and print them out according to authors and according to names
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
