Java教程

student

本文主要是介绍student,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

public class Student extends Person {//学生继承Person
public static int count = 0;
private String studentId;
private String mclass;

public Student() {
super();
count++;
}
public Student(String name) {
super(name);
count++;
}

public Student(String name, String sex, int age, String address, String birthDay,String studentId,String mclass) {
super(name, sex, age, address, birthDay);
this.studentId = studentId;
this.mclass = mclass;
count++;
}

public String getStudentId() {
return studentId;
}
public void setStudentId(String studentId) {
this.studentId = studentId;
}
public String getMclass() {
return mclass;
}
public void setMclass(String mclass) {
this.mclass = mclass;
}

@Override
public String toString() {
return name + “是一个” + sex +“生, Ta已经” + age + “了, Ta出生在” + birthDay + “,Ta家住在” + address

  • “, Ta学号为:” + studentId + “, Ta的专业是:” + mclass ;
    }
    public void work() {
    System.out.println(name + “在学习”);
    }
    }
这篇关于student的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!