不知道哪里错了,求指教
为什么我的查找,修改和删除功能都没有效果?package EMP;
import java.util.*;
import *;
public class Emp
{
/**
* @param args
*/
public static void main(String[] args) throws Exception
{
// TODO Auto-generated method stub
//创建EmpManage对象
EmpManage emp = new EmpManage();
//创建个缓冲输入流来吸收键盘的数据
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//创建一个简易的菜单
while(true)
{
System.out.println("请选择要进行的操作");
System.out.println("1: 添加员工");
System.out.println("2: 查找员工");
System.out.println("3: 遍历员工");
System.out.println("4: 修改工资");
System.out.println("5: 删除员工");
System.out.println("6: 最高和平均工资");
//定义对操作流的操作方式
//以行为单位操作
String operType = br.readLine();
if(operType.equals("1"))
{
System.out.println("请输入新员工ID");
String ID = br.readLine();
System.out.println("请输入新员工姓名");
String name = br.readLine();
System.out.println("请输入新员工工资");
float sal = Float.parseFloat(br.readLine());
EmpMember emp1 = new EmpMember(ID,name,sal);
emp.addEmp(emp1);
}
else if(operType.equals("2"))
{
System.out.println("请输入要查找的员工工号");
String ID = br.readLine();
emp.trackInfo(ID);
}
else if(operType.equals("3"))
{
emp.traverseMember();
}
else if(operType.equals("4"))
{
System.out.println("请输入要修改的员工工号");
String ID = br.readLine();
System.out.println("请输入要修改的工资");
float newsal = Float.parseFloat(br.readLine());
emp.modifySal(ID, newsal);
}
else if(operType.equals("5"))
{
System.out.println("请输入要删除员工的工号");
String ID = br.readLine();
emp.DelMember(ID);
}
else if(operType.equals("6"))
{
emp.stasal();
}
}
}
}
class EmpMember
{
//属性:姓名,工号,工资
private String name;
private String ID;
private float sal;
//构造方法
public EmpMember(String name, String ID, float sal)
{
this.name = name;
this.ID = ID;
this.sal = sal;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getID() {
return ID;
}
public void setID(String iD) {
ID = iD;
}
public float getSal() {
return sal;
}
public void setSal(float sal) {
this.sal = sal;
}
}
class EmpManage
{
//创建一个集合
ArrayList al = new ArrayList();
//EmpMember emp = null;
//添加员工信息
public void addEmp(EmpMember e)
{
al.add(e);
}
//根据工号查找员工
public void trackInfo(String ID)
{
for(int i = 0; i < al.size(); i++)
{
EmpMember emp = (EmpMember) al.get(i);
if(emp.getID().equals(ID))
{
System.out.println("该员工信息如下");
System.out.println("工号="+ID);
System.out.println("姓名="+emp.getName());
System.out.println("工资="+emp.getSal());
}
}
}
//遍历所有员工
public void traverseMember()
{
for(int i = 0; i<al.size();i++)
{
EmpMember emp = (EmpMember) al.get(i);
System.out.println("第"+(i+1)+"员工的信息如下");
System.out.println("工号="+emp.getID());
System.out.println("姓名="+emp.getName());
System.out.println("工资="+emp.getSal());
}
}
//修改某个员工的工资
public void modifySal(String ID, float newsal)
{
for(int i = 0; i < al.size(); i++)
{
EmpMember emp =(EmpMember)al.get(i);
if(emp.getID().equals(ID))
{
emp.setSal(newsal);
}
}
}
//删除某个员工
public void DelMember(String ID)
{
for(int i = 0; i < al.size();i++)
{
EmpMember emp = (EmpMember)al.get(i);
if(emp.getID().equals(ID))
{
al.remove(i);
}
}
}
//统计平均工资和最高工资
public void stasal()
{
float max = 0,average = 0,sum = 0;
int tag;
for(int i = 0; i < al.size();i++)
{
EmpMember emp = (EmpMember)al.get(i);
//求最值
if(emp.getSal() > max)
{
max = emp.getSal();
tag = i;
}
//求均值
sum = sum+emp.getSal();
}
average = sum/al.size();
System.out.println("最高工资为"+max);
System.out.println("平均工资为"+average);
}
}