标签:
abstract classPrinter{
void open(){
System.out.println("open");
}
void close(){
System.out.println("close");
}
abstract void print();
}
//该打印机为喷墨打印机
classHPPrinter extends Printer{
void print(){
System.out.println("使用喷墨打印机打印");
}
}
//该打印机为针式打印机
classCanonPrinter extends Printer{
void print(){
System.out.println("使用针式打印机");
}
}
classTest{
publicstaticvoid main(String args []){
Printer p1 =newHPPrinter();
p1.open();
p1.print();
p1.close();
Printer p2 =newCanonPrinter();
p2.open();
p2.print();
p2.close();
}
}
标签:
原文地址:http://www.cnblogs.com/arroneve/p/5815449.html