- class Test1_Emplyee {
- public static void main(String[] args) {
- Employee e = new Coder("张三","零零发",10000);
- e.work();
- }
- }
- abstract class Employee {
- private String name;
- private String id;
- private double salary;
- public Employee() {}
- public Employee(String name,String id,double salary) {
- this.name = name;
- this.id = id;
- this.salary = salary;
- }
- public void setName(String name) {
- this.name = name;
- }
- public String getName() {
- return name;
- }
- public void setId(String id) {
- this.id = id;
- }
- public String getId() {
- return id;
- }
- public void setSalary(double salary) {
- this.salary = salary;
- }
- public double getSalary() {
- return salary;
- }
- public abstract void work();
- }
- class Coder extends Employee {
- public Coder() {}
- public Coder(String name,String id,double salary) {
- super(name,id,salary);
- }
- public void work() {
- System.out.println("我的姓名是:" + getName() +",工号是" + getId() +",工资是" + getSalary()+",我的工作内容是敲代码.");
- }
- }
复制代码 |
|