上传了实验四,已确认无敏感信息

This commit is contained in:
2024-06-10 16:42:32 +08:00
parent 2da90eeebf
commit c9d2aa581b
16 changed files with 324 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
//Person.java
package Task5;
public abstract class Person {
String name;
String gender;
String birthday;
public abstract void printInfo();
}
+17
View File
@@ -0,0 +1,17 @@
//Student.java
package Task5;
public class Student extends Person {
String school;
String id;
String grade;
public void printInfo() {
System.out.println("name:\t" + this.name);
System.out.println("gender:\t" + this.gender);
System.out.println("birthday:\t" + this.birthday);
System.out.println("school:\t" + this.school);
System.out.println("id:\t" + this.id);
System.out.println("grade\t" + this.grade);
}
}
+15
View File
@@ -0,0 +1,15 @@
//Teacher.java
package Task5;
public class Teacher extends Person {
String school;
String id;
public void printInfo() {
System.out.println("name:\t" + this.name);
System.out.println("gender:\t" + this.gender);
System.out.println("birthday:\t" + this.birthday);
System.out.println("school:\t" + this.school);
System.out.println("id:\t" + this.id);
}
}
+22
View File
@@ -0,0 +1,22 @@
//TestPerson.java
package Task5;
public class TestPerson {
public static void main(String[] args) {
Student s1 = new Student();
s1.name = "Jason Fate Chen";
s1.gender = "male";
s1.birthday = "May.5th.2005";
s1.school = "XJIT";
s1.id = "202301130071";
s1.grade = "1";
s1.printInfo();
Teacher t1 = new Teacher();
t1.name = "White";
t1.gender = "female";
t1.birthday = "Mar.7th.1993";
t1.school = "Tsinghua";
t1.id = "199303071145";
t1.printInfo();
}
}