public class Book implements Comparable { protected int pages; public Book () { pages - 1500; public Book (int pages) { this.pages = pages; public void setPages (int pages) { this.pages = pages; public int getPages () { return pages; /** * Return e if this book has the same number of pages as another book, * -1 if this book has lesser number of pages as another book and * 1 if this book has greater number of pages than another book. public int compareTo(Book another) { // TO DO (missing code segment 1)

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter11: Advanced Inheritance Concepts
Section: Chapter Questions
Problem 10PE
icon
Related questions
Question

Provide the missing code segment in the portion with the TO DO remark in the source code below. 

public class Book implements Comparable<Book> {
protected int pages;
public Book () {
pages = 1580;
public Book (int pages) {
this.pages = pages;
public void setPages (int pages) {
this.pages = pages;
public int getPages () {
return pages;
/**
* Return 0 if this book has the same number of pages as another book,
* -1 if this book has lesser number of pages as another book and
* 1 if this book has greater number of pages than another book.
*/
public int compareTo (Book another) {
// TO DO (missing code segment 1)
Transcribed Image Text:public class Book implements Comparable<Book> { protected int pages; public Book () { pages = 1580; public Book (int pages) { this.pages = pages; public void setPages (int pages) { this.pages = pages; public int getPages () { return pages; /** * Return 0 if this book has the same number of pages as another book, * -1 if this book has lesser number of pages as another book and * 1 if this book has greater number of pages than another book. */ public int compareTo (Book another) { // TO DO (missing code segment 1)
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Class
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
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT