Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

implement and fix first photo, test in 2nd photo java private int totalPages; public Book (String title, Author author, int rating, int totalPages) { this.title

implement and fix first photo, test in 2nd photo
java image text in transcribed
image text in transcribed
private int totalPages; public Book (String title, Author author, int rating, int totalPages) { this.title = "unknown"; this.author = null; this.rating = @; this.totalPages = 0; } public Author getAuthor() { return author; } public int getTotalPages() { return totalPages; } public int getRating() { return rating; } Purpose: determine if the current book is equal to other Parameters: Book other - the other book to compare to Returns: boolean - true if the two books have the same title and author (the same book might have a different number of pages depending on whether the copy is hard-cover or paperback, and might receive different ratings from different reviewers). public boolean equals(Book other) return false; // so it compiles Purpose: determine the percentage the book has been read Parameters: int pagesRead - the number of pages read in this book Returns: double - the percentage of the way the reader has progressed through the book. public double percentageRead(int pagesRead) { return @.@; // so it compiles } public static void testBookconstructor() { System.out.println(" Testing Book Constructor"); Author al = new Author("Gillian", "Flynn", 49); Author a2 = new Author("Veronica", "Roth", 32); Book b1 = new Book ("Gone Girl", al, 5, 432); Book b2 = new Book ("Divergent", a2, 4, 487); int result = 0; int expected = 0; result = 61.getTotalPages(); expected - 432; displayResults("b1 construcutor totalPages initialized", result--expected); result = b2.getRating(); expected = 4; displayResults("b1 construcutor rating initialized", resultunexpected); /* uncomment the following lines to test if the author was initialized correctly: */ Author resultAuthor = null; Author expectedAuthor = null; resultAuthor = b1.getAuthor(); expectedAuthor = a1; displayResults("b1 construcutor author initialized", resultAuthor.equals(expectedAuthor)); resultAuthor - b2.getAuthor(); expectedAuthor = a2; bisplayResults("b2 construcutor author initialized", resultAuthor.equals(expectedAuthor))

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Manga Guide To Databases

Authors: Mana Takahashi, Shoko Azuma, Co Ltd Trend

1st Edition

1593271905, 978-1593271909

More Books

Students also viewed these Databases questions

Question

Question Can a Keogh plan fund be reached by the owners creditors?

Answered: 1 week ago

Question

Question What happens to my plan if I die?

Answered: 1 week ago