package demo;
public class Student {
private String name;//名字
private int age;//年龄
private String gender;//性别
public Student(String name, int age, String gender) {
this.name = name;
this.age = age;
this.gender = gender;
}
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 getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public void introduce() {
System.out.println("大家好!我是" + name + ",今年" + age + "岁," + gender + "生。");
}
public static void main(String[] args) {
System.out.println("大一学生:");
BigOneStudents freshman=new BigOneStudents("张三",18,"男","计算机系","计算机",11001,"1班","党员");
freshman.introduce();
System.out.println("小学生:");
PrimaryStudent primaryStudent=new PrimaryStudent("李四",10,"男",1000,6);
primaryStudent.introduce();
System.out.println("中学生:");
MiddleStudent middleStudent=new MiddleStudent("小美",15,"女",10003,8,"团员");
middleStudent.introduce();
}
}
class PrimaryStudent extends Student {
private int studentId;//学号
private int grade;//年级
public PrimaryStudent(String name, int age, String gender, int studentId, int grade) {
super(name, age, gender);
this.studentId = studentId;
this.grade = grade;
}
public int getStudentId() {
return studentId;
}
public void setStudentId(int studentId) {
this.studentId = studentId;
}
public int getGrade() {
return grade;
}
public void setGrade(int grade) {
this.grade = grade;
}
}
class MiddleStudent extends Student {
private int studentId;
private int grade;
private String politicalStatus;//政治面貌
public MiddleStudent(String name, int age, String gender, int studentId, int grade, String politicalStatus) {
super(name, age, gender);
this.studentId = studentId;
this.grade = grade;
this.politicalStatus = politicalStatus;
}
public int getStudentId() {
return studentId;
}
public void setStudentId(int studentId) {
this.studentId = studentId;
}
public int getGrade() {
return grade;
}
public void setGrade(int grade) {
this.grade = grade;
}
public String getPoliticalStatus() {
return politicalStatus;
}
public void setPoliticalStatus(String politicalStatus) {
this.politicalStatus = politicalStatus;
}
}
class CollegeStudent extends Student {
private String department;//系别
private String major;//专业
public CollegeStudent(String name, int age, String gender, String department, String major) {
super(name, age, gender);
this.department = department;
this.major = major;
}
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
public String getMajor() {
return major;
}
public void setMajor(String major) {
this.major = major;
}
}
class BigOneStudents extends CollegeStudent {
private int studentId;
private String className;
private String politicalStatus;
public BigOneStudents(String name, int age, String gender, String department, String major, int studentId, String className, String politicalStatus) {
super(name, age, gender, department, major);
this.studentId = studentId;
this.className = className;
this.politicalStatus = politicalStatus;
}
public int getStudentId() {
return studentId;
}
public void setStudentId(int studentId) {
this.studentId = studentId;
}
public String getClassName() {
return className;
}
public void setClassName(String className) {
this.className = className;
}
public String getPoliticalStatus() {
return politicalStatus;
}
public void setPoliticalStatus(String politicalStatus) {
this.politicalStatus = politicalStatus;
}
}
class BigTwoStudent extends CollegeStudent {
private int studentId;
private String className;
private String politicalStatus;
public BigTwoStudent(String name, int age, String gender, String department, String major, int studentId, String className, String politicalStatus) {
super(name, age, gender, department, major);
this.studentId = studentId;
this.className = className;
this.politicalStatus = politicalStatus;
}
public int getStudentId() {
return studentId;
}
public void setStudentId(int studentId) {
this.studentId = studentId;
}
public String getClassName() {
return className;
}
public void setClassName(String className) {
this.className = className;
}
public String getPoliticalStatus() {
return politicalStatus;
}
public void setPoliticalStatus(String politicalStatus) {
this.politicalStatus = politicalStatus;
}
}
class BigThreeStudent extends CollegeStudent {
private int studentId;
private String className;
private String politicalStatus;
public BigThreeStudent(String name, int age, String gender, String department, String major, int studentId, String className, String politicalStatus) {
super(name, age, gender, department, major);
this.studentId = studentId;
this.className = className;
this.politicalStatus = politicalStatus;
}
public int getStudentId() {
return studentId;
}
public void setStudentId(int studentId) {
this.studentId = studentId;
}
public String getClassName() {
return className;
}
public void setClassName(String className) {
this.className = className;
}
public String getPoliticalStatus() {
return politicalStatus;
}
public void setPoliticalStatus(String politicalStatus) {
this.politicalStatus = politicalStatus;
}
}