Hi, can i please get assistance with the following Java class to read data below? Add anything relevant if needed only. The author and book classes is given if it is needed. As well as, the sample data file.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Hi, can i please get assistance with the following Java class to read data below?  Add anything relevant if needed only. The author and book classes is given if it is needed. As well as, the sample data file.

public class Author {

private String name;

public Author (String name){

this.name= name;

}

public String toString(){

return name;

}

public boolean equals(Object obj){

return this.toString().equals(obj.toString());

}

public int hashCode(){

return name.hashCode();

}

}

import java.util.*;

public class Book {

private String title;
private double averageRating;
private String ISBN;
private int numPages;
public Set<Author> authors;

public Book(){
authors=new HashSet<>(); //initialise authors
}

public Book(String title, double averageRating, String isbn, int numPages){
this.title = title;
this.averageRating = averageRating;
this.ISBN = isbn;
this.numPages = numPages;
authors=new HashSet<>(); //initialise authors
}

//accessors
public String getTitle(){
return title;
}

public double getAverageRating(){
return averageRating;
}

public String getISBN(){
return ISBN;
}

public int getNumPages(){
return numPages;
}

public String getAuthorList(){
String authorList ="";
for(Author a: authors) //for each Author in collection
authorList+=a.toString(); //append the name to authorList
return authorList;
}

//mutators
public void setTitle(String title){
this.title = title;
}

public void setAverageRating(double averageRating){
this.averageRating = averageRating;
}

public void setISBN(String isbn){
this.ISBN = isbn;
}

public void setNumPages(int numPages){
this.numPages = numPages;
}

public void addAuthor(Author a){
/* Inserts a new Author into the author list. No duplicates are allowed */
authors.add(a); //adds a if not present
}
public boolean isAuthoredBy(Author a){
/* Returns true if the Book is authored by the supplied author
false otherwise */
for(Author auth:authors) //for each Author in collection
{
if(a.equals(auth)) //if auth and a are same
return true;
}
return false;
}

public String toStringTitleFirst(){
return getTitle() + ", " + getAuthorList() + " " + getAverageRating() + ", " + getISBN() + ", " + getNumPages() + " pages.";
}

public String toStringISBNFirst(){
return getISBN() + " " + getTitle() + ", " + getAuthorList() + " " + getAverageRating() + ", " + ", " + getNumPages() + " pages.";
}

public String toStringRatingFirst(){
return getAverageRating() + " " + getTitle() + ", " + getAuthorList() + " " + getISBN() + ", " + ", " + getNumPages() + " pages.";
}

public String toStringPagesFirst(){
return getNumPages() + " pages " + getTitle() + ", " + getAuthorList() + " " + getISBN() + ", " + ", " + getAverageRating() ;
}

public boolean equals(Object obj){
return (Book)obj.getISBN().equals(ISBN); //checks ISBN
}

public int hashCode(){
return ISBN.hashCode();
}
}

DataReader.java: A class that reads data from a sample data file. You will need to modify this class to create Book and Author objects, associate them and then return a filled Book[ ] array. You have to extract the Author data from the lines yourself where the “/“ delimiter separates multiple author names.

import java.io.File;
import java.util.Scanner;
public class DataReader {

public Book[ ] readFile(){
try{
String path = "100books.txt";
File dataFile = new File(path);
Scanner fileReader = new Scanner(dataFile);
String[] bookdetails = new String[5];
String line;
while(fileReader.hasNextLine()) {
line = fileReader.nextLine();
bookdetails = line.split(",");
System.out.println(bookdetails[0] +"," +bookdetails[1]+"," +bookdetails[2]+"," +bookdetails[3]+"," +bookdetails[4]);
}
fileReader.close();
}
catch(Exception e){
System.out.println(e.toString());
}
return null;
}

}

Balzac And The Little Chinese Seamstress, Dai Sijie/Ina Rilke,3.64,9780099452249,172
North Carolina Weekends, Lynn Setzer,3.71,9780895872739,353
The white Widaw, Jim Lehrer, 3.04,9781891620416, 224
Texas! Trilogy, Sandra Brown,4.29,9780385424707,600
Twenty Love Poems and a Song of Despair, Pablo Neruda/w.s. Merwin/Cristina García,4.30,9780143039969,70
Rachel's Holiday (Walsh Family #2), Marian Keyes, 3.95,9780060090388,578
Bloody Bones (Anita Blake Vampire Hunter #5), Laurell K. Hamilton,4.11,9780425205679,336
The Spook's Apprentice (The Last Apprentice / wardstone Chronicles #1),Joseph Delaney, 3.99,9780099456452,325
1912 Manuscript on the Special Theory of Relativity, Albert Einstein/Hanoch Gutfreund,4.41,9780807615324, 174
Hikaru no Go Vol. 8: The Pro Test Preliminaries: Day Four (Hikaru no Go #8),Yumi Hotta/Takeshi Obata,4.22,9781421506425, 205
The Demon Princes Volume One: The Star King The Killing Machine The Palace of Love, Jack Vance,4.25,9780312853020,446
All the King's Men: Three Stage Versions, Robert Penn warren/James A. Perkins/James A. Grimshaw,4.00,9780820320977,264
The Missing Piece Meets the Big 0,Shel Silverstein,4.34,9780060256579, 104
The Stand: Das letzte Gefecht, Stephen King/Joachim Körber,4.34,9783404134113, 1227
The Oedipus Plays of Sophocles: Oedipus the King; Oedipus at Colonus; Antigone, Sophocles/Paul Roche, 3.97,9780452011670, 288
Foxmask (Saga of the Light Isles #2),Juliet Marillier,4.10,9780330411844,670
Seven Plays, Sam Shepard/Richard Gilman,4.18,9780553346114,336
Housekeeping, Marilynne Robinson, 3.82,9780312424091,219
Danny the Champion of the world, Roald Dahl,4.09,9780435122218, 208
La Emperatriz tras el velo (Trilogía Taj Mahal #1), Indu Sundares an/Alberto Coscarelli,4.04,9788425337604,382
Light a Penny Candle, Maeve Binchy, 3.91,9780099498575,832
The Ministry of Special Cases, Nathan Englander, 3.66,9780375404931,339
Flowers of Evil and Other Works/Les Fleurs du Mal et Oeuvres Choisies : A Dual-Language Book (Dover Foreign Language Study Guides) (English and French Edition), Charles
Vixen 03 (Dirk Pitt #5), Clive Cussler,3.84,9780553589443,384
Dragon's Treasure, Elizabeth A. Lynn, 3.54,9780441012596, 336
The spire william Golding : notes, Steve Eddy, 3.60,9781405835640, 135
Statesman, Plato/C.J. Rawe, 3.85,9780872204621, 128
Ports of Call,Jack Vance, 3.55,9780312864743,300
Writings and Selected Narratives of the Exploration and Settlement of Virginia,John Smith,3.39,9781598530018, 1327
Word Freak: Heartbreak Triumph Genius
Hot Spot (Mark Manning Mystery #6), Michael Craft,3.85,9780312313647,288
Rebekah (Women of Genesis #2),0rson Scott Card,3.84,9780765341280,416
Winds of Fate (Valdemar: Mage winds #1), Mercedes Lackey,4.04,9780886775 162,458
Great Short Works, Edgar Allan Poe/Gary Richard Thompson,4.26,9780060830939,576
and Obsession in the World of Competitive Scrabble Players, Stefan Fatsis,3.82,9780142002261,372
Adios Hemingway, Leonardo Padura/John King, 3.72,9781841957951,229
Transcribed Image Text:Balzac And The Little Chinese Seamstress, Dai Sijie/Ina Rilke,3.64,9780099452249,172 North Carolina Weekends, Lynn Setzer,3.71,9780895872739,353 The white Widaw, Jim Lehrer, 3.04,9781891620416, 224 Texas! Trilogy, Sandra Brown,4.29,9780385424707,600 Twenty Love Poems and a Song of Despair, Pablo Neruda/w.s. Merwin/Cristina García,4.30,9780143039969,70 Rachel's Holiday (Walsh Family #2), Marian Keyes, 3.95,9780060090388,578 Bloody Bones (Anita Blake Vampire Hunter #5), Laurell K. Hamilton,4.11,9780425205679,336 The Spook's Apprentice (The Last Apprentice / wardstone Chronicles #1),Joseph Delaney, 3.99,9780099456452,325 1912 Manuscript on the Special Theory of Relativity, Albert Einstein/Hanoch Gutfreund,4.41,9780807615324, 174 Hikaru no Go Vol. 8: The Pro Test Preliminaries: Day Four (Hikaru no Go #8),Yumi Hotta/Takeshi Obata,4.22,9781421506425, 205 The Demon Princes Volume One: The Star King The Killing Machine The Palace of Love, Jack Vance,4.25,9780312853020,446 All the King's Men: Three Stage Versions, Robert Penn warren/James A. Perkins/James A. Grimshaw,4.00,9780820320977,264 The Missing Piece Meets the Big 0,Shel Silverstein,4.34,9780060256579, 104 The Stand: Das letzte Gefecht, Stephen King/Joachim Körber,4.34,9783404134113, 1227 The Oedipus Plays of Sophocles: Oedipus the King; Oedipus at Colonus; Antigone, Sophocles/Paul Roche, 3.97,9780452011670, 288 Foxmask (Saga of the Light Isles #2),Juliet Marillier,4.10,9780330411844,670 Seven Plays, Sam Shepard/Richard Gilman,4.18,9780553346114,336 Housekeeping, Marilynne Robinson, 3.82,9780312424091,219 Danny the Champion of the world, Roald Dahl,4.09,9780435122218, 208 La Emperatriz tras el velo (Trilogía Taj Mahal #1), Indu Sundares an/Alberto Coscarelli,4.04,9788425337604,382 Light a Penny Candle, Maeve Binchy, 3.91,9780099498575,832 The Ministry of Special Cases, Nathan Englander, 3.66,9780375404931,339 Flowers of Evil and Other Works/Les Fleurs du Mal et Oeuvres Choisies : A Dual-Language Book (Dover Foreign Language Study Guides) (English and French Edition), Charles Vixen 03 (Dirk Pitt #5), Clive Cussler,3.84,9780553589443,384 Dragon's Treasure, Elizabeth A. Lynn, 3.54,9780441012596, 336 The spire william Golding : notes, Steve Eddy, 3.60,9781405835640, 135 Statesman, Plato/C.J. Rawe, 3.85,9780872204621, 128 Ports of Call,Jack Vance, 3.55,9780312864743,300 Writings and Selected Narratives of the Exploration and Settlement of Virginia,John Smith,3.39,9781598530018, 1327 Word Freak: Heartbreak Triumph Genius Hot Spot (Mark Manning Mystery #6), Michael Craft,3.85,9780312313647,288 Rebekah (Women of Genesis #2),0rson Scott Card,3.84,9780765341280,416 Winds of Fate (Valdemar: Mage winds #1), Mercedes Lackey,4.04,9780886775 162,458 Great Short Works, Edgar Allan Poe/Gary Richard Thompson,4.26,9780060830939,576 and Obsession in the World of Competitive Scrabble Players, Stefan Fatsis,3.82,9780142002261,372 Adios Hemingway, Leonardo Padura/John King, 3.72,9781841957951,229
Expert Solution
steps

Step by step

Solved in 3 steps with 4 images

Blurred answer
Knowledge Booster
Math class and its different methods
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education