Hi, can i get assistance with this book class in Java please? The comments with the "TODO" is what I need assistance with, thank you! The author class is attached to the question in case there is any relevance for it. public class Book { private String title; private double averageRating; private String ISBN; private int numPages; // TODO: 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; } // TODO: provide an accessor for the book collection public String getAuthorList(){ String authorList =""; // TODO: 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){ // TODO: complete this method /* Inserts a new Author into the author list. No duplicates are allowed */ } public boolean isAuthoredBy(Author a){ // TODO: 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() ; } }

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...
icon
Related questions
Question

Hi, can i get assistance with this book class in Java please? The comments with the "TODO" is what I need assistance with, thank you! The author class is attached to the question in case there is any relevance for it.

public class Book {

private String title;
private double averageRating;
private String ISBN;
private int numPages;
// TODO: 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;
}
// TODO: provide an accessor for the book collection

public String getAuthorList(){
String authorList ="";
// TODO: 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){
// TODO: complete this method
/* Inserts a new Author into the author list. No duplicates are allowed */
}
public boolean isAuthoredBy(Author a){
// TODO: 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() ;
}
}

 

 

Author.java x Book.java
Epublic class Author (
2
private String name,
public Author (String name) {
this.name= name:
11
public String toString () {
13
return name;
14
15
}
16
public boolean equals (Object o) {
18
19
return this.toString ().equals (o.toString () ):
20
21
}
public int hashCode () {
24
25
return name.hashCode ();
26
27
}
28
29
Transcribed Image Text:Author.java x Book.java Epublic class Author ( 2 private String name, public Author (String name) { this.name= name: 11 public String toString () { 13 return name; 14 15 } 16 public boolean equals (Object o) { 18 19 return this.toString ().equals (o.toString () ): 20 21 } public int hashCode () { 24 25 return name.hashCode (); 26 27 } 28 29
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
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 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)
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
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY