Status: Not Started
  • Textbook.java
Font Size
14
Parentheses autocomplete
Wrap lines
Editor
Theme
Code with blocks by default
Console Font Size
12
Console Theme
Show File Tab Bar
2 Textbook Complete (text only)
Textbook.java
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Output
Docs
Exercise
More
This student is viewing this assignment in English. View this page in English?

5 points

The Book class is used to store information about a book. A partial Book class definition is shown.


public class Book

{

/** The title of the book */

private String title;


/** The title of the book */

private double price;


/** Creates a new Book with given title and price */

public Book(String bookTitle, double bookPrice)

{ /* implementation not shown */ }


/** Returns the title of the book */

public String getTitle()

{ return title; }


/** Returns a string containing the title and price of the Book */

public String getBookInfo()

{

return title + "-" + price;

}


// There may be instance variables, constructors, and methods that are not shown

}


You will write a class Textbook, which is a subclass of Book.


A Textbook has an edition number, which is a positive integer used to identify versions of the book. The getBookInfo method, when called on a Textbook, returns a string that also includes the edition information, as shown in the example.


Information about the book title and price must be maintained in the Book class. Information about the edition must be maintained in the Textbook class.


The Textbook class contains an additional method, canSubstituteFor, which returns true if a Textbook is a valid substitute for another Textbook and returns false otherwise. The current Textbook is a valid substitute for the Textbook reference by the parameter of the canSubstituteFor method if the two Textbook objects have the same title and if the edition of the current Textbook is greater than or equal to the edition of the parameter.


The following table contains a sample code execution sequence and the corresponding results. The code execution sequence appears in a class other than Book or Textbook.



Write the complete Textbook class. Your implementation must meet all specification and conform to the examples shown in the preceding table.

Reset Code

Slides and Notes

No slides available for this video

About

Free Response