人和学生的重写方法

public class Student extends Person{
String school;
String sno;
public Student(){
    super();
}

public Student(String school, String sno,String name, int age, String sex) {
    super(name,age,sex);
    this.school = school;
    this.sno = sno;
}

public void study(){
    System.out.println(this.name+"正在"+this.school+"studying");
}

@Override
public void showInfo() {
    super.showInfo();
    System.out.println(this.school);
    System.out.println(this.sno);
}


}
public class Person {
String name;
int age;
String sex;

    public Person() {
    super();
}
    public Person(String name, int age, String sex) {
    super();
    this.name = name;
    this.age = age;
    this.sex = sex;
}
public void eat(){
    System.out.println(this.name+"吃烤肠");
}
public class Planttest {
    public static void main(String[] args) {

    Student s=new Student("蓝翔","222","baby",52,"women");
    s.showInfo();
    
    
    }

}

 

posted @ 2017-04-11 16:44  苏轼的红烧肉  阅读(129)  评论(0编辑  收藏  举报