My debugging and testing process:
A The source code is as follows
Public class Admin extends User {
Public Admin (string name, string call, int age, String sex,
String loginname, string password, string school) {
Super (Name, call, age, sex, loginname, password, school);
}
}
Public class Student extends User {
Public Student (string name, String call, int. age, String sex,
String loginname, string password, string school) {
Super (Name, call, age, sex, loginname, password, school);
}
}
Public class Teacher extends User {
Public Teacher (string name, String call, int. age, String sex,
String loginname, string password, string school) {
Super (Name, call, age, sex, loginname, password, school);
}
}
Public class Test {
Public Static void Main (string[] args) {
UI Test=new UI ();}
}
Import Java.awt.Button;
Import Java.awt.Font;
Import Java.awt.Frame;
Import Java.awt.Label;
Import Java.awt.TextField;
Import java.awt.event.ActionEvent;
Import Java.awt.event.ActionListener;
Import Java.awt.event.WindowAdapter;
Import java.awt.event.WindowEvent;
Import Javax.swing.JFrame;
Import Javax.swing.JOptionPane;
Import Javax.swing.JPasswordField;
public class UI extends JFrame {
TextField Textfield1;
JPasswordField textfield2;
Public UI () {
Final frame frame = new Frame ("Library login System");
Frame.setlayout (NULL);
Final button button1 = New button ("Request Account");
Final button button2 = New button ("Forgot password");
Final button Button3 = New button ("Login");
Final button Button4 = New button ("Exit");
Button1.setbounds (300, 100, 80, 30);
Button2.setbounds (300, 150, 80, 30);
Button3.setbounds (80, 200, 80, 30);
Button4.setbounds (240, 200, 80, 30);
Frame.add (button1);
Frame.add (button2);
Frame.add (Button3);
Frame.add (BUTTON4);
Label Label1 = new Label ("Account:");
Label Label2 = new label ("Password:");
Label label3 = new label ("Library Landing System");
Label1.setbounds (50, 100, 80, 30);
Label2.setbounds (50, 150, 80, 30);
Label3.setbounds (150, 35, 120, 50);
Label3.setfont (New Font ("Arial", Font.plain, 16));
Frame.add (Label1);
Frame.add (Label2);
Frame.add (LABEL3);
Textfield1 = new TextField (20);
Textfield2 = new JPasswordField (20);
Textfield1.setbounds (130, 100, 150, 30);
Textfield2.setbounds (130, 150, 150, 30);
Frame.add (TEXTFIELD1);
Frame.add (TEXTFIELD2);
Frame.setbounds (425, 600, 400, 300);
Frame.setresizable (FALSE);
Frame.setvisible (TRUE);
Frame.addwindowlistener (New Windowadapter () {
public void windowclosing (WindowEvent arg0) {
Frame.dispose ();
}
});
Button3.addactionlistener (new ActionListener () {
public void actionperformed (ActionEvent e) {
Login ();
}
});
Button4.addactionlistener (new ActionListener () {
public void actionperformed (ActionEvent e) {
System.exit (0);
}
});
}
private void Login () {
User u1 = new Teacher ("A", "admin", 45, "male", "1001", "007", "Qilu Polytechnic University");
User U2 = new Student ("B", "Teacher", 35, "male", "1002", "008", "Qilu University of Technology");
User U3 = new Admin ("C", "classmate", 20, "male", "1003", "009", "Qilu University of Technology");
if (Textfield1.gettext (). Equals (U1.loginname)
&& textfield2.gettext (). Equals (U1.password)) {
Joptionpane.showmessagedialog (NULL, U1.read ());
}
if (Textfield1.gettext (). Equals (U2.loginname)
&& textfield2.gettext (). Equals (U2.password)) {
Joptionpane.showmessagedialog (NULL, U2.read ());
}
if (Textfield1.gettext (). Equals (U3.loginname)
&& textfield2.gettext (). Equals (U3.password)) {
Joptionpane.showmessagedialog (NULL, U3.read ());
}
}
}
Public class User {
Public String name;
Public String call;
Public int age;
Public String LoginName;
Public String PassWord;
Public String School;
Public String sex;
Public User (string name, string call, int age, String sex,
String loginname, string password, string school) {
this. Name = name;
this. Call = call;
this. Age = age;
this. loginName = LoginName;
this. PassWord = PassWord;
this. School = school;
this. Sex = sex;
}
Public String Read () {
return "Welcome" + call + "Login library \ n" + "\ n" + "profile as below \" + "Name:" + Name
+ "\ n" + "Age:" + "Gender:" +sex + ages + "\ n" + "School:" + School;
}
}
Two: The error code in the program has been successfully corrected by our team, I will highlight the test results:
The code debugging and testing process has been successfully demonstrated, you can run the code through the line debugging, what comments can be feedback to me.
---------------------------------------------------Guo Shutao;
Testing and commissioning