Back to slide -- Keyboard shortcut: 'u'        next  Literature.java - Den abstrakte klasse Literature.Lecture 8 - slide 9 : 26
Program 1

package microbib;

/** The root class of literature hierarchy. The general properties
of literatere are title (a string) and year (an integer). */

public abstract class Literature {

  protected String literatureTitle;
  protected int literatureYear;

  protected Literature(String ttl, int yr)
   {literatureTitle = ttl; literatureYear = yr;}
    
  /** Return my title */
  public String title(){return literatureTitle;}

  /** Return the year I am published */
  public int year(){return literatureYear;}

  /** Print this literature object */
  abstract protected void printItem(); 

  /** Print this literature object with a surrounding frame of stars */
  public void print()
  {
   System.out.print("***************************************************");
   printItem();
   System.out.println();
   System.out.print("***************************************************");
   System.out.println();
  }

  /** Returns whether I match the search string parameter */
  public boolean match(String searchString) {
    return title().indexOf(searchString) >= 0;
  }
}