![](https://cos-cdn.shuashuati.com/pipixue-web/2020-1231-2005-12/ti_inject-812ce.png)
程序填空题2:继承与多态 。 项目描述:在学校管理系统中,有三种用户,系统管理员、学生和教师,编写Java类实现该继承关系。系统管理员/学生/教师用户名和密码属性,并Login和显示自身信息的方法,另外,学生拥有班级属性,教师拥有部门属性,系统管理员可以添加学生和教师信息。由于教师和学生个人信息不同,所以学生和教师重写基类的DisplayInfo方法。 请将程序补充完整,实现相应功能。 //1、父类User的定义 class User { String userName;// 用户名 String password;// 密码 int userType;// 用户类型:1代表学生,2代表教师,3代表管理员 User(String userName, String password) { this.userName = userName; this.password = password; } public void Login() { if (userName.equals("123") && password.equals("123")) { System.out.println("登录成功!"); } else { System.out.println("登录失败!"); } } public void DisplayPersonInfo() { System.out.println("姓名:" + userName); System.out.println("用户类型:" + userType); } } //2、子类student、teacher的定义 ___________ Student ___________ User { String classID; Student(String userName, String password, String classID) { ___________ (userName, password); super.userType = ___________;//1代表学生 ___________ .classID = classID; } public void DisplayPersonInfo() { ______________.DisplayPersonInfo(); System.out.println("班级:" + this.classID); } } class Teacher extends User{ String department; public Teacher(String userName, String password, String department) { super(userName, password); super.userType = 2;//2代表教师 this.department = department; } public void DisplayPersonInfo() { super.DisplayPersonInfo(); System.out.println("部门:" + this.department); } } //3、子类Sysmanager的定义 class SysManager extends User{ public SysManager(String userName, String password) { super(userName, password); super.userType = 3; //3代表管理员 } //插入学生方法,这里仅仅是模拟,现实中,要插入到数据库中。 public void InsertStudent(Student s) { ____________.DisplayPersonInfo(); } public void InsertTeacher (Teacher t) { t.DisplayPersonInfo(); } } public class TestUser { public static void main(String[] args) { Student s=____________ Student("123","123", "310163"); ___________.DisplayPersonInfo(); s.Login(); Teacher t = new Teacher("", "123", "计通院"); t.DisplayPersonInfo(); t.Login(); SysManager admin=new SysManager("admin", "123"); admin.___________________(s); } }