复习
需求:
编写一个抽象类:职员Employee,其中定义showSalary(int s)抽象方法;编写Employee的子类,分别是销售员Sales和经理Manager,分别在子类中实现对父类抽象方法的重写,并编写测试类Test查看输出结果
package cn.employee.test;public abstract class Employee {abstract void showSalary(int s);
}
package cn.employee.test;public class Manager extends Employee {@Overridevoid showSalary(int s) {System.out.println("Manager:" + s);}}
package cn.employee.test;public class Sales extends Employee {@Overridevoid showSalary(int s) {System.out.println("Sales:" + s);}}
package cn.employee.test;public class Test2 {public static void main(String[] args) {Employee s = new Sales();Employee m = new Manager();s.showSalary(50000);m.showSalary(80000);}}