16.2
16.2
(4)职员注册:点击用户登录页面的“注册”按钮,顾客进入用户注册页面,注册信息包括姓名、性别(男或女单选)、手机号码(11位数字)、部门、职位。(4分)(WEB端)
后端代码
import java.util.*;
// 职员类
class Employee {
private String userID;
private String userName;
private String sex;
private String department;
private String phone;
private String position;
static final String JDBC_DRIVER = "com.mysql.cj.jdbc.Driver";
static final String JDBC_URL = "jdbc:mysql://localhost:3306/meeting?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC";
private static final String JDBC_USER = "root";
private static final String JDBC_PASSWORD = "123456";
// 构造函数
public Employee(String userID, String userName, String sex, String department, String phone, String position) {
this.userID = userID;
this.userName = userName;
this.sex = sex;
this.department = department;
this.phone = phone;
this.position = position;
}
// 获取职员ID
public String getUserID() {
return userID;
}
// 获取姓名
public String getUserName() {
return userName;
}
// 获取性别
public String getSex() {
return sex;
}
// 获取部门
public String getDepartment() {
return department;
}
// 获取手机
public String getPhone() {
return phone;
}
// 获取职位
public String getPosition() {
return position;
}
// 获取详细信息
public String getDetails() {
return "职员ID:" + userID + "\n姓名:" + userName + "\n性别:" + sex + "\n部门:" + department + "\n手机:" + phone + "\n职位:" + position;
}
}
// 系统管理员类
class Admin {
private List<Employee> employeeList;
// 构造函数
public Admin() {
this.employeeList = new ArrayList<>();
}
// 添加职员
public void addEmployee(Employee employee) {
employeeList.add(employee);
}
// 获取职员列表
public List<Employee> getEmployeeList() {
return employeeList;
}
// 通过职员ID查找职员
public Employee findEmployeeByID(String userID) {
for (Employee employee : employeeList) {
if (employee.getUserID().equals(userID)) {
return employee;
}
}
return null;
}
}
import java.util.*;
// 职员类
class Employee {
private String userID;
private String userName;
private String sex;
private String department;
private String phone;
private String position;
static final String JDBC_DRIVER = "com.mysql.cj.jdbc.Driver";
static final String JDBC_URL = "jdbc:mysql://localhost:3306/meeting?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC";
private static final String JDBC_USER = "root";
private static final String JDBC_PASSWORD = "123456";
// 构造函数
public Employee(String userID, String userName, String sex, String department, String phone, String position) {
this.userID = userID;
this.userName = userName;
this.sex = sex;
this.department = department;
this.phone = phone;
this.position = position;
}
// 获取职员ID
public String getUserID() {
return userID;
}
// 获取姓名
public String getUserName() {
return userName;
}
// 获取性别
public String getSex() {
return sex;
}
// 获取部门
public String getDepartment() {
return department;
}
// 获取手机
public String getPhone() {
return phone;
}
// 获取职位
public String getPosition() {
return position;
}
// 获取详细信息
public String getDetails() {
return "职员ID:" + userID + "\n姓名:" + userName + "\n性别:" + sex + "\n部门:" + department + "\n手机:" + phone + "\n职位:" + position;
}
}
// 系统管理员类
class Admin {
private List<Employee> employeeList;
// 构造函数
public Admin() {
this.employeeList = new ArrayList<>();
}
// 添加职员
public void addEmployee(Employee employee) {
employeeList.add(employee);
}
// 获取职员列表
public List<Employee> getEmployeeList() {
return employeeList;
}
// 通过职员ID查找职员
public Employee findEmployeeByID(String userID) {
for (Employee employee : employeeList) {
if (employee.getUserID().equals(userID)) {
return employee;
}
}
return null;
}
}

浙公网安备 33010602011771号