定义Employee类中存储员工信息

在entity包中Employlee类中创建实体类,
public class Employee {
	private int userId;
	private String userName;
	private String password;
	private int roleId;
	private String empNo;
	private int departId;
	private double salary;

}

自动生成属性的get set方法在Employee类体 中右键 选择Source-----Generate Getters and Setters或shift+alt+s

单击select all选中要生成get set方法的属性 单击ok效果如下

public int getUserId() {
		return userId;
	}
	public void setUserId(int userId) {
		this.userId = userId;
	}
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public int getRoleId() {
		return roleId;
	}
	public void setRoleId(int roleId) {
		this.roleId = roleId;
	}
	public String getEmpNo() {
		return empNo;
	}
	public void setEmpNo(String empNo) {
		this.empNo = empNo;
	}
	public int getDepartId() {
		return departId;
	}
	public void setDepartId(int departId) {
		this.departId = departId;
	}
	public double getSalary() {
		return salary;
	}
	public void setSalary(double salary) {
		this.salary = salary;
	}
	

3 为employee类编写构造方法,显示信息displayInfo()和修改密码的方法modifyPassword()

public Employee(){
		
	}
	public Employee(int userId,String empNo,String userName,String password,int departId,int roleId,double salary){
		this.userId=userId;
		this.empNo=empNo;
		this.userName=userName;
		this.password =password;
		this.departId =departId;
		this.roleId=roleId;
		this.salary=salary;
		
	}
	public void displayInfo(){
		String position=null;
		if(roleId==1)
			position="Staff";
		if(roleId==2)
			position="Manager";
		if(roleId==3)
			position="Admin";
		String department=null;
		if(departId==1)
			department="市场部";
		if(departId==2)
			department="开发部";
		if(departId==3)
			department="信息部";
		System.out.println("\t\t当前用户信息\n\n");
		System.out.println("*********************************");
		System.out.println("\t\t雇员编号:"+empNo);
		System.out.println("\t\t姓名:"+userName);
		System.out.println("\t\t职务:"+position);
		System.out.println("\t\t部门:"+department);
		System.out.println("\t\t薪水:"+String.valueOf(salary));
		System.out.println("*********************************");
	}
	/**
	 * 修改密码
	 * @param newPassword
	 */
	public void modifyPassword(String newPassword){
		this.password=newPassword;
		System.out.println("密码谢盖成功");
	}


  • 4
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值