public abstract class PaperItem { private String title; private String content; public PaperItem(String title, String content) { this.title = title; this.content = content; } public String getTitle() { return title; } public String getContent() { return content; } public abstract void print(); public abstract void archive(); } public class Book extends PaperItem { private String author; public Book(String title, String content, String author) { super(title, content); this.author = author; } public String getAuthor() { return author; } @Override public void print() { System.out.println("Printing book - Title: " + getTitle() + ", Author: " + author); System.out.println(getContent()); } @Override public void archive() { System.out.println("Archiving book - Title: " + getTitle() + ", Author: " + author); } } public class PaperItemFrameworkTest { public static void main(String[] args) { book.print(); book.archive(); } }


上一篇:
下一篇:
切换中文