/**
* @author 984519762@qq.com
* 基类
*/
public class Person {
private String name;//姓名
private String age;//年龄
public Person() {
super();
}
public Person(String name, String age) {
super();
this.name = name;
this.age = age;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAge() {
return age;
}
public void setAge(String age) {
this.age = age;
}
@Override
public String toString() {
return "Person [name=" + name + ", age=" + age + "]";
}
}
/**
* @author 984519762@qq.com
* 子类继承父类的name,age两个属性
* 自身一个属性score
*/
public class Student extends Person{
private String score;//分数
public Student(String name,String age,String score) {
super(name,age);
this.score = score;
}
public String getScore() {
return score;
}
public void setScore(String score) {
this.score = score;
}
public void print(){
System.out.print("name= " + getName() + " age= " + getAge() + " score= " + score);
}
public static void main(String[] args){
Student student = new Student("wuyongpeng", "24", "80");
student.print();
}
}