1.编码创建一个打印类Printer,定义抽象方法print();创建两个子类,即针式打印机类DotMatrixPrinter和喷墨打印机类LnkpetPrinter,并在各自类中重写方法print(),编写测试类实现两种打印机打印,在添加一个激光打印机子类LaserPrinter,重写方法print(),修改测试类实现该打印机打印。
package com.homework.demo.test5_5;
/**
* 打印机抽象父类
* @author suixin
*
*/
public abstract class Printer {
/**
* 抽象打印方法
*/
public abstract void print();
}
package com.homework.demo.test5_5;
/**
* 针式打印机类
* @author suixin
*
*/
public class DotMatrixPrinter extends Printer{
@Override
public void print() {
// TODO Auto-generated method stub
System.out.println("针式打印机");
}
}
package com.homework.demo.test5_5;
/**
* 喷墨打印机类
* @author suixin
*
*/
public class InkpetPrinter extends Printer{
@Override
public void print() {
// TODO Auto-generated method stub
System.out.println("喷墨打印机");
}
}
package com.homework.demo.test5_5;
/**
* 激光打印机类
* @author