标签:main matrix style 打印 开始 test span com nbsp
1 package com.kehou.print; 2 3 /** 4 * 父类:打印机类 5 * @author 6 * 7 */ 8 public abstract class Printer { 9 public abstract void print(); 10 }
1 package com.kehou.print; 2 3 /** 4 * 子类:针式打印机类 5 * @author 6 * 7 */ 8 public class DotMatrixPrinter extends Printer{ 9 10 public void print() { 11 System.out.println("这是针式打印机,开始打印了......."); 12 } 13 14 }
1 package com.kehou.print; 2 3 /** 4 * 喷墨打印机类 5 * @author 6 * 7 */ 8 public class InkpetPrinter extends Printer { 9 10 public void print() { 11 System.out.println("这是喷墨打印机,开始打印了......"); 12 } 13 14 }
1 package com.kehou.print; 2 3 /** 4 * 激光打印机类 5 * @author 6 * 7 */ 8 public class LaserPrinter extends Printer { 9 10 public void print() { 11 System.out.println("这是激光打印机,开始打印了......"); 12 } 13 14 }
1 package com.kehou.print; 2 3 public class Test { 4 5 public static void main(String[] args) { 6 Printer dmp=new DotMatrixPrinter(); 7 dmp.print(); 8 9 Printer ipp=new InkpetPrinter(); 10 ipp.print(); 11 12 Printer lp=new LaserPrinter(); 13 lp.print(); 14 } 15 16 }
标签:main matrix style 打印 开始 test span com nbsp
原文地址:https://www.cnblogs.com/baichang/p/10066922.html