某航空公司在其航班到达的不同的国家的不同地方设有不同的办事处,这个项目要求开发一个自动化软件系 统,该系统将提供给这些办事处的管理者(role=1)和普通用户(role=0)用于管理航班信息。根据以上描述,要 求实现系统的用户模块和办事处模块,包含以下功能(注:系统存在一个默认管理员admin/admin123):
用户模块:
- 用户添加
- 密码修改
- 个人信息查看
- 账号状态修改(禁用0、启用1)
- 用户登录(被禁用账号无法登录并提示友好的消息)
- 修改用户角色(设置取消管理员)
- 用户列表
- 删除用户
办事处模块 - 办事处添加
- 办事处列表
. 3. 查询指定办事处的所有员工 注意:管理员具备以上所有功能,普通用户只有密码修改和个人信息查看功能。 参考类如下:
15. 用户类(User):
id,账号(username),密码(passord),年龄(age),角色(role),邮箱(email),办事处id(officeID),账户状态 (status)
办事处类(Office):
id,办公室名(officeName)
解题步骤:
首先创建一个User类,定义id,账号(username),密码(passord),年龄(age),角色(role),邮箱(email),办事处id(officeID),账户状态 (status) 的所有属性为私有属性,添加无参和有参构造方法,重写toString方法(将想要输出的内容按字符串的方式输出)
代码如下:**
package com;
public class User {
private int id;
private String username;
private int age;
private String role;
private String email;
private int officeID;
private String status;
public User() {
// TODO Auto-generated constructor stub
}
public User(int id, String username, int age, String role, String email, int officeID, String status) {
super();
this.id = id;
this.username = username;
this.age = age;
this.role = role;
this.email = email;
this.officeID = officeID;
this.status = status;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public int getOfficeID() {
return officeID;
}
public void setOfficeID(int officeID) {
this.officeID = officeID;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
@Override
public String toString() {
return "User [ID=" + id + ", 账户=" + username + ", 年龄=" + age + ",