设计一个person类,包括姓名、性别、年龄等属性和info()方法,设计一个student类继承person类,包括学校、班级等属性,重写info()方法,介绍自己的基本信息,包括学习成绩的排名,成绩排名要求从键盘输入。在控制台输出相关信息。要求:对象名以自己名字的缩写字母加学号后两位命名。如张三2020148101命名为:zs01
class Person {
private String name;
private int age;
private String sex;
public Person(String name, int age, String sex) {
this.name = name;
this.age = age;
this.sex = sex;
}
public void setName(String name) {this.name = name;}
public String getName() {return this.name;}
public void setAge(int age) {this.age = age;}
public String getAge() {return this.age;}
public void setSex(String sex) {this.sex = sex;}
public String getSex() {return this.sex;}
}
public class Student extends Person{
private String school;
public Student(String school, String name, int age, String sex) {
super(name, age, sex);
this.school = school;
}
public void setSchool(String school) {this.school = school;}
public String getSchool() {return this.school;}
public void static main(String[] args) {
Person s1 = new Student("清华大学", "刘备", 18, "男");
}
}