package com.HelloWorld;//雇员公有特性abstract class Employee{ private String name; private String id; private double pay; Employee(String name, String id, double pay){ this.name = name; this.id = id; this.pay = pay; } abstract public void work(); }//程序员class Programmer extends Employee{ Programmer(String name, String id, double pay){ super(name, id, pay); } public void work(){ System.out.println("敲代码...."); } /*public String toString (){ return ; }*/}//经理class Manager extends Employee{ private int bonus; Manager(String name, String id, double pay, int bonus){ super(name,id,pay); this.bonus = bonus; } public void work(){ System.out.println("管理..."); } /*public String toString(){ return ; }*/}public class AbstractTest { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Employee p = new Programmer("xiaoming", "xiaoming123", 100); Employee m = new Manager("xiaohu", "xiaohu456",123, 12); p.work(); m.work(); System.out.println(p); System.out.println(m); }}请问为了将我填入的属性输出,输出语句中该怎么写?
添加回答
举报
0/150
提交
取消