public String id;
public abstract void doPrint();
}
public class Printer3d extends Printer{
public Printer3d() {
super();
// TODO Auto-generated constructor stub
}
public Printer3d(String num){
this.id = "3D"+num;
}
@Override
public void doPrint() {
System.out.println("3d: "+id + "在打印");
}
}
public class PrinterBW extends Printer{
public PrinterBW() {
super();
}
public PrinterBW(String num) {
super();
id ="BW"+num;
}
public void doPrint (){
System.out.println("!!!! :"+this.id+"正在打印");
}
@Override
public String toString() {
return "PrinterBW [id=" + id + "]";
}
}
public class PrinterColor extends Printer{
public PrinterColor() {
super();
// TODO Auto-generated constructor stub
}
public PrinterColor(String id) {
super();
this.id ="Color"+id;
}
@Override
public String toString() {
return "PrinterColor [id=" + id + "]";
}
public void doPrint(){
System.out.println("++++ :"+this.id+"正在打印");
}
}