package hrm3;
import java.lang.Math;
import java.util.Random;
import java.util.Scanner;
public class Employee {
public String id;
public String name;
public int age;
public String sex;
public String job;
public int work_time;
public String Department;
private int salary;
private int award;
public static int count=0;
public Employee()
{
count++;
Scanner sc=new Scanner(System.in);
System.out.println("请输入你的姓名:");
name=sc.nextLine();
System.out.println("请输入你的性别:");
sex=sc.nextLine();
System.out.println("请输入你的年龄:");
age=sc.nextInt();
System.out.println("请问你准备工作几个月:");
work_time=sc.nextInt();
setSalary();
System.out.println("恭喜你已经成为我们公司的一员");
assign_id();
distribute_department();
assign_job();
}
//输出个人信息
public void ouput()
{
System.out.println("职工号:"+id);
System.out.println("姓名:"+name);
System.out.println("年龄"+age);
System.out.println("性别:"+sex);
System.out.println("职务:"+job);
System.out.println("部门:"+Department);
GiveOutAward();
setSalary();
System.out.println();
}
//生成职工号
public void assign_id()
{
String base="0123456789";
Random random=new Random();
StringBuffer sb=new StringBuffer();
for(int i=0;i<7;i++)
{
int num=random.nextInt(base.length());
sb.append(base.charAt(num));
}
id=sb.toString();
System.out.println("你的职工号为:"+id);
}
//分配部门
public void distribute_department()
{
String[] str= {"研发部","市场部","销售部","生产部","财务部"};
Random random=new Random();
int num=random.nextInt(str.length);
Department=str[num];
System.out.println("你所在的部门为:"+Department);
}
//设置职务
public void assign_job()
{
String[] ss= {"董事长","总经理","财务总监","会计","人事经理","销售经理","普通职工","高级职工","特级工程师"};
Random random=new Random();
int num=random.nextInt(ss.length);
job=ss[num];
System.out.println("你的职务为:"+job);
}
//分配奖金
public void GiveOutAward()
{
int res=1000000;
if(this.job.equals("董事长"))res=1000000;
else if(this.job.equals("总经理"))res=500000;
else if(this.job.equals("财务总监"))res=400000;
else if(this.job.equals("人事经理"))res=400000;
else if(this.job.equals("销售经理"))res=700000;
else if(this.job.equals("特级工程师"))res=500000;
else if(this.job.equals("会计"))res=200000;
else if(this.job.equals("高级职工"))res=500000;
else res=200000;
award=res;
System.out.println("你的奖金是"+award);
}
//计算薪水
public void setSalary()
{
int res=10000;
if(this.job.equals("董事长"))res=10000;
else if(this.job.equals("总经理"))res=8000;
else if(this.job.equals("财务总监"))res=7000;
else if(this.job.equals("人事经理"))res=6000;
else if(this.job.equals("销售经理"))res=7000;
else if(this.job.equals("特级工程师"))res=6000;
else if(this.job.equals("会计"))res=3000;
else if(this.job.equals("高级职工"))res=5000;
else res=3000;
salary=res*work_time;
}
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
int n;
System.out.print("请输入要录入员工的人数:");
n=sc.nextInt();
Employee employee[]=new Employee[n];
for(int i=0;i<n;i++)
employee[i]=new Employee();
System.out.print("员工人数:"+Employee.count);
Random random=new Random();
int i=random.nextInt(count);//随机显示某个员工的薪水
employee[i].ouput();
}
}
//随便输入的测试数据
请输入要录入员工的人数:3
请输入你的姓名:
光头强
请输入你的性别:
男
请输入你的年龄:
30
请问你准备工作几个月:
12
恭喜你已经成为我们公司的一员
你的职工号为:5912946
你所在的部门为:研发部
你的职务为:销售经理
请输入你的姓名:
李老板
请输入你的性别:
男
请输入你的年龄:
45
请问你准备工作几个月:
3
恭喜你已经成为我们公司的一员
你的职工号为:6631781
你所在的部门为:研发部
你的职务为:财务总监
请输入你的姓名:
熊大
请输入你的性别:
男
请输入你的年龄:
12
请问你准备工作几个月:
7
恭喜你已经成为我们公司的一员
你的职工号为:3332233
你所在的部门为:研发部
你的职务为:高级职工
员工人数:3职工号:3332233
姓名:熊大
年龄12
性别:男
职务:高级职工
部门:研发部
你的奖金是500000