Hi, can i please get assistance with the following Java class below, where there is "TO DO:" I would like the task to be done please.  Add anything relevant if needed only. The author class and the book class description is given.

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
100%

Hi, can i please get assistance with the following Java class below, where there is "TO DO:" I would like the task to be done please.  Add anything relevant if needed only. The author class and the book class description is given.

public class Book {

private String title;
private double averageRating;
private String ISBN;
private int numPages;
// TO DO: insert an appropriate collection for associating Authors and initialise within constructors

public Book(){
}

public Book(String title, double averageRating, String isbn, int numPages){
this.title = title;
this.averageRating = averageRating;
this.ISBN = isbn;
this.numPages = numPages;
}

//accessors
public String getTitle(){
return title;
}
public double getAverageRating(){
return averageRating;
}
public String getISBN(){
return ISBN;
}
public int getNumPages(){
return numPages;
}
// TO DO: provide an accessor for the collection on line 9

public String getAuthorList(){
String authorList ="";
// TO DO: insert code to return all author names separated by commas if multiple authors
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){
// TO DO: complete this method
/* Inserts a new Author into the author list. No duplicates are allowed */
}
public boolean isAuthoredBy(Author a){
// TO DO: complete this method -
/* Returns true if the Book is authored by the supplied author
false otherwise */
return false;
}

//variety of String representations of a Book

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() ;
}
}

Book.java: A class that models a book which has a title, average rating, ISBN number and number
of pages. A book needs to have a collection of authors, and several other methods. Book objects
with the same ISBN should be considered identical. You will need to override the equals(),
hashCode( ) methods. Examine the Java class carefully for more details on what needs to be
completed as indicated by the comments in the code.
Transcribed Image Text:Book.java: A class that models a book which has a title, average rating, ISBN number and number of pages. A book needs to have a collection of authors, and several other methods. Book objects with the same ISBN should be considered identical. You will need to override the equals(), hashCode( ) methods. Examine the Java class carefully for more details on what needs to be completed as indicated by the comments in the code.
Author.java
public class Author (
private String name;
public Author (String name) {
this.name= name;
}
public String toString () {
return name:
}
public boolean equals (Object o) {
return this.toString ().equals (o.toString () ));
public int hashCode () {
return name.hashCode ();
}
28
29
30
31
Transcribed Image Text:Author.java public class Author ( private String name; public Author (String name) { this.name= name; } public String toString () { return name: } public boolean equals (Object o) { return this.toString ().equals (o.toString () )); public int hashCode () { return name.hashCode (); } 28 29 30 31
Expert Solution
steps

Step by step

Solved in 2 steps

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
  • SEE MORE 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