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;
}
};
分享到:
相关推荐
【标题】和【描述】提及的是幼儿园老师写给家长的感谢信,这通常是教育领域中的一种情感交流,表达对老师辛勤工作的感激之情。虽然【标签】是“技术”,但实际内容与技术无关,而是关于幼儿教育和家长与教师之间的...
#### 家长给教师写的感谢信(一) 1. **孩子成长的细节**:信中提到了孩子在老师的关心下克服午睡困难、及时更换尿湿的衣物等细节,体现了老师对学生无微不至的关怀。 2. **教师的耐心与责任**:描述了老师即使面对...
c 抓包程序(老师写的) 这次的程序写的很好。TCP。IP, UDP, ARP包
8. **教师写给学生的赠言举例**:这些赠言富含哲理,如“勤奋是一只蜜蜂,能帮助你酿造幸福之蜜”,强调努力的重要性;“做人失败,任何成功都不算真正的成功;做人成功,任何失败都不算真正的失败”,引导学生重视...
1. **文档格式与编辑工具**:虽然文档标题为“谢谢老师写的一封信.doc”,但这里的".doc"指的是Microsoft Word文档格式,是一种常见的文本编辑工具,用于创建和编辑文档,包括信件、报告、论文等各种类型的文本内容...
计算器(老师写).c
给老师写毕业赠言.doc
教师写给学生的赠言.doc
教师写给学生的寄语.doc
老师写给学生的寄语.doc
老师写给学生的留言.doc
如何给老师写一封信.doc
班主任老师写给学生述职报告.pdf
班主任老师写给学生述职报告.docx
老师写给我们全体家长们感谢信.pdf
学生给自己老师写一封信精选.doc
班主任老师写给学生的述职报告.docx
关于中班老师写给家长的感谢信.doc
这是用strtus,hibernate写的,是模仿韩顺平老师视频的留言本写的,主要实现用户登录可以查看谁给自己发送的信息,如果有错误的地方希望指出qq1272307737
李煌老师为你们呕心沥血写的程序,若遇见且珍惜