The Book class is used to store information about a book. A partial Book class definition is 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 different 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 referenced 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.

public class Textbook extends Book
//Define class called textbook
//Since we are using a super class we need to extend book
{
    private int edition;
    
    public Textbook(String t, double p, int e)
    //Constructor called Textbook passes through parameters for title, price, and edition
    //Each parameter has a different primative that need to be listed before hand
    {
        super(t, p);
        //This helps to take care for both the title and the price
        this.edition = e;
    }
    public int getEdition()
    //By creating this public int, we can have the computer return our book title name
    {
        return edition;
    }
    public String getBookInfo()
    {
        return super.getBookInfo() + "-" + edition;
        //This returns the title of the book, along with both the price and the edition
    }
    public boolean canSubstituteFor(Textbook other)
    //canSubstituteFor means that if two books have the same title, it will access the edition number and if the current textbook edition is greater than or equal to the edition of the parameter
    {
        return getTitle().equals(other.getTitle()) && this.edition >= other.getEdition();
    }
}
|   public class Textbook extends book
cannot find symbol
  symbol:   class book

|           return super.getBookInfo() + "-" + edition;
non-static variable super cannot be referenced from a static context

|           return super.getBookInfo() + "-" + edition;
cannot find symbol
  symbol: method getBookInfo()

|           return getTitle().equals(other.getTitle()) && this.edition >= other.getEdition();
cannot find symbol
  symbol:   method getTitle()

|           return getTitle().equals(other.getTitle()) && this.edition >= other.getEdition();
cannot find symbol
  symbol:   method getTitle()