l老师写的

package a;

import java.io.*;

interface Work
{
	String communication();
	boolean promote();
	float completion();
}

class Employee implements Work
{
	protected String strEmpID;
	protected char chrGender;
	protected String strTelNumber;
	protected double dblSalary;
	//沟通能力等级
	protected int communication_Level;
	//完成任务指标度
	protected float completion;
	
	Employee(String strEmpID,char chrGender,String strTelNumber,double dblSalary,int communication_Level,float completion)
	{
		this.strEmpID = strEmpID;
		this.chrGender = chrGender;
		this.strTelNumber = strTelNumber;
		this.dblSalary = dblSalary;
		this.completion = completion;
		this.communication_Level = communication_Level;
	}

	public double getDblSalary()
	{
		return dblSalary;
	}

	public void setDblSalary(double dblSalary)
	{
		this.dblSalary = dblSalary;
	}

	public String getStrEmpID()
	{
		return strEmpID;
	}

	public void setStrEmpID(String strEmpID)
	{
		this.strEmpID = strEmpID;
	}
	
	public void  raiseSalary(double dblProportion)
	{
		dblSalary *= 1+dblProportion;
	}

	public String toString()
	{
		return "员工编号: "+strEmpID+" 性别: "+chrGender+" 员工电话: "+strTelNumber+" 员工薪资: "+dblSalary;
	}

	public String communication()
	{
		switch(communication_Level)
		{
			case 1:
			{
				return "差强人意";
			}
			case 2:
			{
				return "良好";
			}
			case 3:
			{
				return "好";
			}
			case 4:
			{
				return "优秀";
			}
			default:
			{
				return "暂无评价";
			}
		}
	}

	public boolean promote()
	{
		if(communication_Level==4&&completion>0.9f)
		{
			return true;
		}
		else
		{
			return false;
		}
	}

	public float completion()
	{
		return completion;
	}

};

class Manager extends Employee
{
	protected String strOfficeID;
	protected double dblBonus;

	Manager(String strEmpID,char chrGender,String strTelNumber,double dblSalary,int communication_Level,float completion,String strOfficeID)
	{
		super(strEmpID,chrGender,strTelNumber,dblSalary,communication_Level,completion);
		this.strOfficeID = strOfficeID;
	}

	public double getDblBonus()
	{
		return dblBonus;
	}

	public void setDblBonus(double dblBonus)
	{
		this.dblBonus = dblBonus;
	}

	public String getStrOfficeID()
	{
		return strOfficeID;
	}

	public void setStrOfficeID(String strOfficeID)
	{
		this.strOfficeID = strOfficeID;
		
	}
	
	public void  raiseSalary(double dblProportion)
	{
		dblSalary *= 1.1+dblProportion;
	}

	public String toString()
	{
		return "员工编号: "+strEmpID+" 性别: "+chrGender+" 员工电话: "+strTelNumber+" 员工薪资: "+dblSalary+" 所在部门: "+strOfficeID;
	}
};

class EmployeeTest
{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	Employee emp = null;
	SaveData sd = new SaveData();
	Employee[] e = null;

	public void batch_Add() throws Exception
	{
		boolean iscontinue = true;
		do
		{
			System.out.println("请输入员工编号:");
			String id = br.readLine();
			System.out.println("请输入员工性别:");
			char chrGender = br.readLine().charAt(0);
			System.out.println("请输入员工电话:");
			String tel = br.readLine();
			System.out.println("请输入员工薪资:");
			double s = Double.parseDouble(br.readLine());
			System.out.println("请输入员工沟通等级:");
			int level = Integer.parseInt(br.readLine());
			System.out.println("请输入员工完成任务程度:");
			float comp = Float.parseFloat(br.readLine());

			System.out.println("请选择员工类型:1--普通员工 2--经理");
			String type = br.readLine();

			if("1".equals(type))
			{
				//产生一般员工对象
				emp = new Employee(id,chrGender,tel,s,level,comp);
			}
			else
			{
				if("2".equals(type))
				{
					System.out.println("请输入所在部门:");
					String office = br.readLine();
					//产生经理对象
					emp = new Manager(id,chrGender,tel,s,level,comp,office);
				}
				else
				{
					System.out.println("输入有误!请重新录入");
					continue;
				}
			}
			//存储对象
			if(sd.add(emp))
			{
				//询问是否结束输入 y--结束 其他键继续
				System.out.println("是否结束输入 y--结束 其他键继续");
				String con = br.readLine();

				if("y".equals(con))
				{
					iscontinue = false;
					//输出所有录入对象
					e = sd.getE();
					for(int i=0;i<sd.getCount();i++)
					{
						System.out.println(e[i]);
					}
				}
			}
			else
			{
				System.out.println("存储数据失败!请再次录入!");
			}
		}
		while (iscontinue);
	}

	public void work_State()
	{
		if(e!=null)
		{
			for(int i=0;i<sd.getCount();i++)
			{
				System.out.println("员工编号:"+sd.getE()[i].strEmpID+"沟通能力"+sd.getE()[i].communication_Level+"工作能力力"+sd.getE()[i].communication());
			}
		}
		else
		{
			System.out.println("无员工记录,请先录入");
		}
	}

	public void promote_List()
	{
	boolean isPromote=false;
		if(e!=null)
		{
			
				for(int i=0;i<sd.getCount();i++)
				{
					if(e[i].promote())
					{
					  System.out.println(e[i]+"沟通能力"+e[i].completion+"工作能力"+e[i].communication());
					  isPromote=true;
				    }
					
			  }
			if(isPromote==false)
			{
				System.out.println("没有可以升迁的员工列表");
			}
		}
		else
		{
			System.out.println("无员工记录,请先录入");
		}
	}

	public void oparation() throws Exception
	{
		System.out.println("请选择操作类型(1--4):1--批量录入 2--查看员工工作状况 3--查看可升迁员工列表");
		char type = br.readLine().charAt(0);
		switch(type)
		{
			case '1':
			{
				batch_Add();
				break;
			}
			case '2':
			{
				work_State();
				break;
			}
			case '3':
			{
				promote_List();
				break;
			}
			default:
			{
				System.out.println("输入无效");
			}
		}
	}
	public static void main(String[] args) throws Exception
	{
		EmployeeTest et = new EmployeeTest();
		while(true)
		{
			et.oparation();
		}
	}

};

 

package a;

class SaveData
{
	private static Employee[] e = new Employee[2];
	//计数器
	static int count;
	//增容
	public void increase()
	{
		//产生一个比原数组更大的数组
		Employee[] newE = new Employee[2*e.length];
		//将原数组数据放入新数组
		for(int i=0;i<e.length;i++)
		{
			newE[i] = e[i];
		}
		//将e引用指向新数组,数组的重新定向
		e = newE;
	}
	//获取存储数组
	public Employee[] getE()
	{
		return e;
	}
	public boolean add(Employee emp)//声明一个函数
	{
		if(count>=e.length)
		{
			increase();
		}
		e[count] = emp;
		count++;
		return true;
	}

	public int getCount()
	{
		return count;
	}
};

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值