雇员查询系统java代码 查询雇员姓名,职位,领导姓名

java编写程序 。。import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class EmployeeTest{
public EmployeeTest(){
}
public static void main(String[] args) {
Employee employee=getInfo();
System.out.println("您输入的雇员信息为:");
System.out.println("编号:" employee.getNumber()
"\n姓名:" employee.getName()
"\n部门号:" employee.getDeptNumber());
}
private static Employee getInfo(){
Employee employee=new Employee();
Scanner s=new Scanner(System.in);
String info="";
System.out.print("请输入姓名:");
info=s.nextLine();
employee.setName(info);
System.out.print("请输入编号:");
info=s.nextLine();
Pattern p=Pattern.compile("^[1-9]{1}\\d $");
Matcher matcher=p.matcher(info);
while(!matcher.matches()){
System.out.print("格式错误,请重新输入编号:");
info=s.nextLine();
matcher=p.matcher(info);
}
employee.setNumber(Integer.parseInt(info));
System.out.print("请输入部门号:");
info=s.nextLine();
Pattern p2=Pattern.compile("^[1-5]{1}$");
matcher=p2.matcher(info);
while(!matcher.matches()){
System.out.print("格式错误 , 请重新输入部门号:");
info=s.nextLine();
matcher=p2.matcher(info);
}
employee.setDeptNumber(Integer.parseInt(info));
return employee;
}
}
public class Employee{
private String name;
private int number;
private int deptNumber;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getNumber() {
return number;
}
public void setNumber(int number) {
this.number = number;
}
public int getDeptNumber() {
return deptNumber;
}
public void setDeptNumber(int deptNumber) {
this.deptNumber = deptNumber;
}
}
一、java编写一个雇员类:1.属性:员工编号,姓名,职位,工资,2.方法包括:输出基本信息 , 计算class Worker {
private String no;
private String name;
private String job;
private double wages;
public Worker() {
super();
}
public Worker(String no, String name, String job, double wages) {
super();
this.no = no;
this.name = name;
this.job = job;
this.wages = wages;
}
public String getWorkerInfo() {
return "员工编号:"no";姓名:"name";职位:"job";工资:"wages;
}
public double getPackage() {
return wages * 12;
}
}
class Salesman extends Worker {
private double bonus;
public Salesman() {
super();
}
public Salesman(double bonus) {
super();
this.bonus = bonus;
}
@Override
public String getWorkerInfo() {
return super.getWorkerInfo()";奖金:"bonus;
}
@Override
public double getPackage() {
return super.getPackage()bonus;
}
}
用Java定义一个类来描述公司雇员,类命名为Employee公司雇员类代码:
/**
* 公司雇员类
*
* @author qd
*
*/
public class Employee {
private String first_name;
private String last_name;
// 雇员id
private long employee_id;
private String email;
private String phone_number;
// 入职日前
private String hire_date;
// 工作id
private long job_id;
private double salary;
// 经理id号
private long manager_id;
public Employee() {
super();
}
public Employee(String first_name, String last_name, long employee_id, String email, String phone_number,
String hire_date, long job_id, double salary, long manager_id) {
super();
this.first_name = first_name;
this.last_name = last_name;
this.employee_id = employee_id;
this.email = email;
this.phone_number = phone_number;
this.hire_date = hire_date;
this.job_id = job_id;
this.salary = salary;
this.manager_id = manager_id;
}
public String getFirst_name() {
return first_name;
}
public void setFirst_name(String first_name) {
this.first_name = first_name;
}
public String getLast_name() {
return last_name;
}
public void setLast_name(String last_name) {
this.last_name = last_name;
}
public long getEmployee_id() {
return employee_id;
}
public void setEmployee_id(long employee_id) {
this.employee_id = employee_id;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPhone_number() {
return phone_number;
}
public void setPhone_number(String phone_number) {
this.phone_number = phone_number;
}
public String getHire_date() {
return hire_date;
}
public void setHire_date(String hire_date) {
this.hire_date = hire_date;
}
public long getJob_id() {
return job_id;
}
public void setJob_id(long job_id) {
this.job_id = job_id;
}
public double getSalary() {
return salary;
}
public void setSalary(double salary) {
this.salary = salary;
}
public long getManager_id() {
return manager_id;
}
public void setManager_id(long manager_id) {
this.manager_id = manager_id;
}
@Override
public String toString() {
return "Employee [first_name="first_name", last_name="last_name", employee_id="employee_id
", email="email", phone_number="phone_number", hire_date="hire_date", job_id="
job_id", salary="salary", manager_id="manager_id"]";
}
}
测试类代码以及效果:
JAVA创建5个雇员对象,设计程序找出五个雇员对象中年龄最大的员工,并将该员工的信息输出到控制台的代码 。class Employee {//雇员类
int age;
//所有信息
}
class Test{
List list = new ArrayList();
//声明创建五个对象
//比如Employee a = new Employee();
//......a.age = 30;
list.add(a);
//五个对象都加入List集合中
//然后遍历取出雇员查询系统java代码,比较年龄
for(int i=0;ilist.size;i)
{
//取出年龄最大雇员查询系统java代码的对象e
}
//输出e雇员查询系统java代码的所有信息
System.out.println(e.age"其雇员查询系统java代码他信息");
}
【雇员查询系统java代码 查询雇员姓名,职位,领导姓名】雇员查询系统java代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于查询雇员姓名,职位,领导姓名、雇员查询系统java代码的信息别忘了在本站进行查找喔 。

    推荐阅读