public class AbstractTest {
public static void main(String[] args) {
}
}
abstract class Creature{
public abstract void breath();
}
abstract class Person extends Creature{
String name;
int age;
public Person() {
}
public Person(String name,int age ) {
this.name = name;
this.age = age;
}
public abstract void eat();
public void walk() {
System.out.println("人走路");
}
}
class Student extends Person{
public Student(String name,int age) {
super(name,age);
}
public void eat() {
System.out.println("学生多吃有营养的事物");
}
@Override
public void breath() {
System.out.println("学生应该呼吸新鲜的空气");
}
}
public abstract class Employee {
private String name;
private int id;
private double salary;
public Employee() {
super();
}
public Employee(String name, int id, double salary) {
super();
this.name = name;
this.id = id;
this.salary = salary;
}
public abstract void work();
}
public class Manager extends Employee{
private double bonus;
public Manager(double bonus) {
super();
this.bonus = bonus;
}
public Manager(String name, int id, double salary, double bonus) {
super(name, id, salary);
this.bonus = bonus;
}
@Override
public void work() {
System.out.println("管理员工,提高公司运行效率");
}
}
public class CommonEmployee extends Employee {
@Override
public void work() {
System.out.println("员工在一线车间生产产品");
}
}
public class EmployeeTest {
public static void main(String[] args) {
Employee manager = new Manager("库克",1001,5000,500000);
manager.work();
CommonEmployee commonEmployee = new CommonEmployee();
commonEmployee.work();
}
}