![]() | Lecture 8 - slide 9 : 26 |
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;
}
}