-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPerson.java
101 lines (56 loc) · 1.97 KB
/
Person.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package action;
import java.sql.SQLException;
import connect.sqlAction;
public class Person {
Person(String id){
this.id = id;
String command = "SELECT name,information FROM "+ getType(this.id) +"WHERE ID = '" + this.id+"';";
sqlAction s = new sqlAction();
s.executeSQL(command);
name = s.rs.getString("name");
info = s.rs.getString("information");
}
Person(String id,String password){
this.id = id;
this.password = password;
String command = "SELECT name,information FROM "+ getType(this.id) +"WHERE ID = '" + this.id+"';";
sqlAction s = new sqlAction();
s.executeSQL(command);
name = s.rs.getString("name");
info = s.rs.getString("information");
}
public String id;
public String name;
public String password;
public String inputPassword;
public String info;
public boolean testRegist() throws SQLException {
connect.sqlAction.executeSQL("SELECT PASSWORD FROM" + getType(id) + "WHERE "+ id.charAt(0) +"_id = '"+ id +"';");
password = connect.sqlAction.getString("password");
return inputPassword == password ? true:false;
}
public String getType(String id) {
if (id.charAt(0) == 's') return "student";
else if (id.charAt(0) == 't') return "teacher";
else if (id.charAt(0) == 'a') return "administration";
else return "wrong";
}
public String getName() throws SQLException {
return name;
}
public String getInfo() throws SQLException{
return info;
}
public void setInfo(String info) throws SQLException {
String command = "UPDATE "+ getType(this.id) +"SET information ='"+info+"' WHERE id = '" + this.id+"';";
sqlAction.executeSQL(command);
}
public void setName(String name){
String command = "UPDATE" + getType(this.id)+"SET name = '"+name+"' WHERE id ='"+this.id+";";
sqlAction.executeSQL(command);
}
public void setPassword(String password){
String command = "UPDATE" + getType(this.id)+"SET password = '"+password+"' WHERE id ='"+this.id+";";
sqlAction.executeSQL(command);
}
}