用JAVA定义一个people类,包含属性name,sex。为people派生一个之类Eemployee类,为其增加两个属性age和grade。grade分等级A,B,C三个等级。
时间: 2024-05-12 08:19:05 浏览: 68
```java
public class People {
private String name;
private String sex;
public People(String name, String sex) {
this.name = name;
this.sex = sex;
}
public String getName() {
return name;
}
public String getSex() {
return sex;
}
}
public class Employee extends People {
private int age;
private String grade;
public Employee(String name, String sex, int age, String grade) {
super(name, sex);
this.age = age;
this.grade = grade;
}
public int getAge() {
return age;
}
public String getGrade() {
return grade;
}
}
```
阅读全文