您的位置:首页 > 其它

员工管理系统Map版

2017-08-15 19:00 127 查看
员工信息的基本情况

普通员工
属性:员工编号、员工姓名、员工职务、请假天数、基本工资
普通员工工资:
在基本工资的基础上增加10%的工作餐,50%的岗位补助,200元住房补助
基本工资+基本工资*0.1+基本工资*0.5+200
经理
属性:员工编号、员工姓名、员工职务、请假天数、基本工资
经理工资:
在基本工资的基础上增加20%的工作餐,50%的岗位补助,500元住房补助
基本工资+基本工资*0.2+基本工资*0.5+500
董事
属性:员工编号、员工姓名、员工职务、请假天数、基本工资
董事工资:
在基本工资的基础上增加8%的工作餐,30%的岗位补助,2000元住房补助,3000元投资补助
基本工资+基本工资*0.08+基本工资*0.3+2000+3000
工资扣除部分,所有员工都一样 
无请假,基本工资全发,有请假,扣除每天平均工资
* 请假天数
Employee类:

/**
* @author 作者 E-mail:
* @date 创建时间:2017年8月14日下午2:59:15
* @version 1.0
* @description 员工管理
* @parameter
* @since
* @return
*/

public class Employee {

private String ID;//员工编号
private String name;//员工姓名
private String position;//员工职务
private int holiday;//请假天数
private double salary;//基本工资
public Employee() {
super();
}
public Employee(String iD, String name, String position, int holiday, double salary) {
super();
ID = iD;
this.name = name;
this.position = position;
this.holiday = holiday;
this.salary = salary;
}
public String getID() {
return ID;
}
public void setID(String iD) {
ID = iD;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPosition() {
return position;
}
public void setPosition(String position) {
this.position = position;
}
public int getHoliday() {
return holiday;
}
public void setHoliday(int holiday) {
this.holiday = holiday;
}
public double getSalary() {
return salary;
}
public void setSalary(double salary) {
this.salary = salary;
}
@Override
public String toString() {
return "编号:" + ID + "\t姓名:" + name + "\t职务:" + position + "\t请假天数:" + holiday + "\t工资:"
+ sumSalary();
}

//工资计算方法
public double sumSalary(){

return salary - salary/30*holiday;
}
//显示详细信息
public void display(){

}
}
CommonEmployee类:
/**
* @author 作者 E-mail:
* @date 创建时间:2017年8月14日下午2:59:51
* @version 1.0
* @description 普通员工
* @parameter
* @since
* @return
*/

public class CommonEmployee extends Employee {

private double commonSalary;

public CommonEmployee(String iD, String name, String position, int holiday, double salary) {
super(iD, name, position, holiday, salary);
commonSalary = 0;
}

public CommonEmployee() {
super();
}

@Override
public double sumSalary() {
double base = super.sumSalary();
commonSalary = base + getSalary()*0.1+getSalary()*0.5+200;
return commonSalary;
}

@Override
public void display() {

System.out.println("编号:" + super.getID() + "\t姓名:" + super.getName() + "\t职务:" + super.getPosition() + "\t请假天数:" + super.getHoliday() + "\t工资:"
+ sumSalary());
}

}
Manager类:
/**
* @author 作者 E-mail:
* @date 创建时间:2017年8月14日下午3:00:05
* @version 1.0
* @description 经理
* @parameter
* @since
* @return
*/

public class Manager extends Employee{

private double managerSalary;

public Manager() {
super();
}

public Manager(String iD, String name, String position, int holiday, double salary) {
super(iD, name, position, holiday, salary);
managerSalary = 0;
}

@Override
public double sumSalary() {
double base = super.sumSalary();
managerSalary = base + getSalary()*0.2+getSalary()*0.5+500;
return managerSalary;
}

@Override
public void display() {

System.out.println("编号:" + super.getID() + "\t姓名:" + super.getName() + "\t职务:" + super.getPosition() + "\t请假天数:" + super.getHoliday() + "\t工资:"
+ sumSalary());
}
}
Director类:
/**
* @author 作者 E-mail:
* @date 创建时间:2017年8月14日下午3:00:41
* @version 1.0
* @description 董事
* @parameter
* @since
* @return
*/

public class Director extends Employee {

private double directorSalary;

public Director(String iD, String name, String position, int holiday, double salary) {
super(iD, name, position, holiday, salary);
directorSalary = 0;
}

public Director() {
super();
}

@Override
public double sumSalary() {
double base = super.sumSalary();
directorSalary = base+getSalary()*0.08+getSalary()*0.3+2000+3000;
return directorSalary;
}
@Override
public void display() {

System.out.println("编号:" + super.getID() + "\t姓名:" + super.getName() + "\t职务:" + super.getPosition() + "\t请假天数:" + super.getHoliday(
9a4d
) + "\t工资:"
+ sumSalary());
}
}
TestEMD类:
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Scanner;

/**
* @author 作者 E-mail:
* @date 创建时间:2017年8月14日下午3:01:01
* @version 1.0
* @description
* @parameter
* @since
* @return
*/

public class TestEMD {
static Scanner sc = new Scanner(System.in);
static Map<String, Employee> map = new HashMap<>();

public static void main(String[] args) {

MainUI();

}

static void MainUI(){

System.out.println("|-------------------|");
System.out.println("|------1 增加-------|");
System.out.println("|------2 删除-------|");
System.out.println("|------3 修改-------|");
System.out.println("|------4 查询-------|");
System.out.println("|------0 退出-------|");
System.out.println("|-------------------|");
System.out.println("请选择业务:");
int sele = sc.nextInt();

switch (sele) {
case 1:
//增
addEmployee();

break;
case 2:
//删
delEmployee();
break;
case 3:
//改
updateEmployee();
break;
case 4:
//查
queryEmployee();
break;
case 0:
//退出
sc.close();
System.out.println("谢谢使用");
System.exit(0);
break;
default:
System.out.println("请按要求输入!");
MainUI();
break;
}

}

/**
* 添加员工
*/
private static void addEmployee() {

Employee employee;
System.out.println("请输入员工编号:");
Scanner scanner = new Scanner(System.in);
String ID = scanner.nextLine();
System.out.println("请输入员工姓名:");
String name = scanner.nextLine();
System.out.println("请输入员工职务(普通员工,经理,董事长):");
String position = scanner.nextLine();
System.out.println("请输入员工请假天数:");
int holiday = scanner.nextInt();
System.out.println("请输入员工基本工资:");
double salary = scanner.nextDouble();

switch (position) {
case "普通员工":
employee = new CommonEmployee(ID, name, position, holiday, salary);
map.put(ID, employee);
System.out.println("添加数据成功");
employee.display();
break;
case "经理":
employee = new Manager(ID, name, position, holiday, salary);
map.put(ID, employee);
System.out.println("添加数据成功");
employee.display();
break;
case "董事长":
employee = new Director(ID, name, position, holiday, salary);
map.put(ID, employee);
System.out.println("添加数据成功");
employee.display();
break;
default:
break;
}
System.out.println("已有员工:");
for (Employee employee2 : map.values()) {
employee2.display();
}
MainUI();
}

/**
* 删除员工
*/
private static void delEmployee() {
Scanner scanner = new Scanner(System.in);
System.out.println("请输入员工姓名:");
String name = scanner.nextLine();
Collection<Employee> values = map.values();
Iterator<Employee> iterator = values.iterator();
while (iterator.hasNext()) {
Employee employee = (Employee) iterator.next();
if (employee.getName().equals(name)) {
employee.display();
System.out.println("确认删除?(1.是2.否)");
int n = scanner.nextInt();
if (n==1) {
map.remove(employee.getID());
System.out.println("删除成功");
MainUI();
}else {
MainUI();
}
}

}
System.out.println("无此员工");
MainUI();
}

/**
* 修改员工信息
*/
private static void updateEmployee() {
System.out.println("请输入修改员工姓名:");
Scanner scanner = new Scanner(System.in);
String name = scanner.nextLine();
Collection<Employee> values = map.values();
Iterator<Employee> iterator = values.iterator();
while (iterator.hasNext()) {
Employee employee = (Employee) iterator.next();
if (employee.getName().equals(name)) {
employee.display();
map.remove(employee.getID());
System.out.println("请重新输入:");
System.out.println("请输入员工编号:");
Scanner scanner1 = new Scanner(System.in);
String ID = scanner1.nextLine();
System.out.println("请输入员工姓名:");
String name1 = scanner1.nextLine();
System.out.println("请输入员工职务(普通员工,经理,董事长):");
String position = scanner1.nextLine();
System.out.println("请输入员工请假天数:");
int holiday = scanner1.nextInt();
System.out.println("请输入员工基本工资:");
double salary = scanner1.nextDouble();

switch (position) {
case "普通员工":
employee = new CommonEmployee(ID, name1, position, holiday, salary);
map.put(ID, employee);
System.out.println("修改数据成功");
employee.display();
break;
case "经理":
employee = new Manager(ID, name1, position, holiday, salary);
map.put(ID, employee);
System.out.println("修改数据成功");
employee.display();
break;
case "董事长":
employee = new Director(ID, name1, position, holiday, salary);
map.put(ID, employee);
System.out.println("修改数据成功");
employee.display();
break;
default:
break;
}
}else {

System.out.println("无此员工");
}

}
MainUI();
}

/**
* 查询员工
*/
private static void queryEmployee() {
Scanner scanner = new Scanner(System.in);
System.out.println("请输入员工姓名:");
String name = scanner.nextLine();
Collection<Employee> values = map.values();
Iterator<Employee> iterator = values.iterator();
while (iterator.hasNext()) {
Employee employee = (Employee) iterator.next();
if (employee.getName().equals(name)) {
employee.display();

MainUI();
}else {
System.out.println("无此员工");
MainUI();
}
}

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: