package HspLearningPoly.poly01.PolyArr;
public class Person {
private String name;
private int age;
public Person(String name, int age) {
this.name = name;
this.age = age;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String say(){//返回名字和年龄
return name+"\t"+age;
}
}
package HspLearningPoly.poly01.PolyArr;
public class Teacher extends Person{
private double salary;
public Teacher(String name, int age, double salary) {
super(name, age);
this.salary = salary;
}
public double getSalary() {
return salary;
}
public void setSalary(double salary) {
this.salary = salary;
}
public String say(){
return super.say()+" salary= "+salary;
}
public void teach(){
System.out.println("老师"+getName()+"正在上课...");
}
}
网友评论