1.编译说30行( void supervise()那儿)缺少方法主体,或声明抽象,这是什么问题?2.Manager里的构造函数里的第四个参数不能起为bonus么?一开始我起叫bonus无法通过,后来改成b就通过了,求人解答一下为什么
- class Employee
- {
- String name;
- int age;
- int salary;//定义姓名,年龄,工资
- Employee(String name,int age,int salary)//构造函数
- {
- this.name = name;
- this.age = age;
- this.salary = salary;
- }
- void work()
- {
- System.out.println("work");
- }
- }
- class Manager extends Employee//经理还有奖金
- {
- int bonus;
- Manager(String name, int age,int salary,int b)
- {
- super(name,age,salary);
-
- this.bonus = b;
- }
-
- void supervise();
- {
- System.out.println("supervise");
- }
- }
- class Demo
- {
- public static void main(String[] args)
- {
- Manager m = new Manager("Zhang san",30,3000,4000);
- m.work();
- m.supervise();
- }
- }
复制代码
|
|