public class StreamDemo04 {
public static void main(String[] args) {
/*
1. 员工信息 (包含名称, 性别, 工资, 奖金, 处罚记录)两个部门分别4个员工,5个员工
2. 分别筛选处2各部门的最高工资的员工信息, 封装成优秀员工对象Topperformer
3. 分别统计出2各部门的平均月收入, 要求去掉最高工资和最低工资
4. 统计2个开发部门整体的平均工资, 去掉最低和最高工资的平均值
*/
ArrayList<Employee> one = new ArrayList<>();
one.add(new Employee("猪八戒",'男',30000,25000,null));
one.add(new Employee("孙悟空",'男',25000,1000,"顶撞上司"));
one.add(new Employee("沙僧",'男',20000,20000,null));
one.add(new Employee("小白龙",'男',20000,25000,null));
ArrayList<Employee> two = new ArrayList<>();
two.add(new Employee("武松",'男',15000,9000,null));
two.add(new Employee("李逵",'男',20000,10000,null));
two.add(new Employee("西门庆",'男',50000,100000,"被打"));
two.add(new Employee("潘金莲",'女',3500,1000,"被打"));
two.add(new Employee("武大郎",'男',20000,0,"下毒"));
//1.开发一部的最高工资的员工
System.out.println(one.stream().max(new Comparator<Employee>() {
@Override
public int compare(Employee o1, Employee o2) {
return Double.compare(o1.getSalary()+ o1.getBonus(),o2.getSalary()+ o2.getBonus()) ;
}
}));
//1.开发一部的最高工资的员工
Employee max = one.stream().max(new Comparator<Employee>() {
@Override
public int compare(Employee o1, Employee o2) {
return Double.compare(o1.getSalary()+ o1.getBonus(),o2.getSalary()+ o2.getBonus()) ;
}
}).get();
sout.println max
}
}