Question
// class BookGenre package library.service.classes; public enum BookGenre {GENRE_HISTORY,GENRE_SCIENCE,GENRE_ENGINEERING,GENRE_LITERATURE}; // class BookRecord package library.service.classes;//set up the package import library.service.classes.BookGenre; public class BookRecord{ int recordNo; String
// class BookGenre
package library.service.classes; public enum BookGenre {GENRE_HISTORY,GENRE_SCIENCE,GENRE_ENGINEERING,GENRE_LITERATURE};
// class BookRecord
package library.service.classes;//set up the package
import library.service.classes.BookGenre;
public class BookRecord{
int recordNo;
String title;
String []authors;
BookGenre genre;
static int cnt=10000;
/on-default constructor
public BookRecord(String title, String genre, String [] name){
this.setTitle(title);
this.setGenre(genre);
this.setAuthors(name);
this.setRecordNo();
}
//accessors
public String getTitle(){
return this.title;
}
public BookGenre getGenre(){
return this.genre;
}
public String [] getAuthors(){
String []ret = new String[this.authors.length];
for(int i=0;i ret[i]=this.authors[i]; } return ret; } public String getAuthorList(){ String ret=""; for(int i=0;i ret=ret + " " +this.authors[i]; } return ret; } public int getRecordNo(){ return this.recordNo; } //mutators public void setRecordNo(){ this.recordNo=BookRecord.cnt++; } public void setTitle(String title){ this.title=title; } public void setGenre(String genre){ this.genre=BookGenre.valueOf(genre); } public void setAuthors(String []authorList){ this.authors = new String[authorList.length]; for(int i=0;i this.authors[i]=authorList[i]; } } //toString method public String toString(){ String str=""; str = str + "=================================== "; str = str + "Record No:" + this.getRecordNo() + " "; str = str + "Title:" + this.getTitle() + " "; str = str + "Genre: " + this.getGenre() + " "; str = str + "Authors: " + this.getAuthorList() + " "; str = str + "=================================== "; return str; } //toEquals method public boolean equals(BookRecord aRecord){//remember you should not compare the record no if(!this.getTitle().equals(aRecord.getTitle())) return false; if(!this.equalsHelper(aRecord)) return false; return true; } private boolean equalsHelper(BookRecord aRecord){ for(int i=0;i if(!this.authors[i].equals(aRecord.authors[i])){ //assume the authors will always be provided in the same order return false; } } return true; } } // class library package library.client.classes; import java.util.Scanner; import java.io.File; import java.io.IOException; import library.service.classes.BookGenre; import library.service.classes.BookRecord; import java.util.Vector; class library{ /*Task 1: Declare the vector of objects*/ Vector //books.txt Thomas Jefferson and the Tripoli Pirates:GENRE_HISTORY:Brian Kilmeade,Don Yaeger Component-oriented programming:GENRE_ENGINEERING:C. Szyperski,J. Bosch,W. Weck Microfabricated microneedles, a novel approach to transdermal drug delivery:GENRE_ENGINEERING:S. Henry,D. V. McAllister,M. G. Allen Nikola Tesla:GENRE_HISTORY:Sean Patrick English landscaping and literature, 1660-1840:GENRE_LITERATURE:E. Malins A history and theory of informed consent:GENRE_HISTORY:R. R. Faden,T. L. Beauchamp,N. M. King The Feminist Companion to Literature in English Women Writers From the Middle Ages to the Present:GENRE_LITERATURE:V. Blain,P. Clements,I. Grundy Climate and atmospheric history of the past 420,000 years:GENRE_HISTORY:J. R. Petit, J. Jouzel,D. Raynaud,N. I. Barkov,J. M. Barnola The comparative method in evolutionary biology:GENRE_SCIENCE:P. H. Harvey,M. D. Pagel Human-computer interaction:GENRE_ENGINEERING:J. Preece,Y. Rogers,H. Sharp,D. Benyon,S. Holland Free radicals in biology and medicine:GENRE_SCIENCE:B. Halliwell,J. M. C. Gutteridge Electron transfers in chemistry and biology:GENRE_SCIENCE:R. A. Marcus,N. Sutin English landscaping and literature, 1660-1840:GENRE_LITERATURE:E. Malins Device electronics for integrated circuits:GENRE_ENGINEERING:R. S. Muller,T. I. Kamins,M. Chan,P. K. Ko An outline of English literature:GENRE_LITERATURE:G. C. Thornley,G. Roberts Gene Ontology:GENRE_SCIENCE:M. Ashburner,C. A. Ball,J. A. Blake,D. Botstein,H. Butler Nikola Tesla:GENRE_HISTORY:Sean Patrick Microfabricated microneedles, a novel approach to transdermal drug delivery:GENRE_ENGINEERING:S. Henry,D. V. McAllister,M. G. Allen
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