标签:
classPrinter{
void open(){
System.out.println("open");
}
void close(){
System.out.println("close");
}
void print(String s){
System.out.println("print-->"+ s);
}
}
classHPPrinter extends Printer{
}
classCanonPrinter extends Printer{
void close(){
this.clean();
super.close();
}
void clean(){
System.out.println("clean");
}
}
classTest{
publicstaticvoid main(String args []){
int flag =1;
if(flag ==0){
HPPrinter hpPrinter =newHPPrinter();
hpPrinter.open();
hpPrinter.print("abc");
hpPrinter.close();
}
elseif(flag ==1){
CanonPrinter canonPrinter =newCanonPrinter();
canonPrinter.open();
canonPrinter.print("123");
canonPrinter.close();
}
}
}
标签:
原文地址:http://www.cnblogs.com/arroneve/p/5815445.html