
正文
员工类型代码Java 员工类型编码
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
用Java语言定义一个员工类Employee
public class Employee {
private String id; // 员工ID号
private String name; // 姓名
private int age; // 年龄
private boolean sex; // 性别(其中:true表示男,false表示女)
private String phone; // 联系电话
private float salary; // 薪水
Employee(String sId, String sName, int sAge, boolean sSex, String sPhone,
float sSalary) {
this.id = sId;
this.name = sName;
this.age = sAge;
this.sex = sSex;
this.phone = sPhone;
this.salary = sSalary;
}
public String toString() {
return "员工ID号:" + this.id + "\n员工姓名:" + this.name + "\n员工年龄:"
+ this.age + "\n员工性别:" + (this.sex == true ? "男" : "女")
+ "\n联系电话:" + this.phone + "\n薪水:" + this.salary;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public float getSalary() {
return salary;
}
public void setSalary(float salary) {
this.salary = salary;
}
public boolean isSex() {
return sex;
}
public void setSex(boolean sex) {
this.sex = sex;
}
}
相关问答
Q1: java设计一个员工类employee,
package com.test;
public class Employee {
private String name;
private int id;
private String address;
private double salary;
public Employee(){ //无参构造器
}
public Employee(String name,int id,String address,double salary){ //构造器
this.name = name;
this.id = id;
this.address = address;
this.salary = salary;
}
public double js(){ //计算工资员工类型代码Java的方法
return 0;
}
public String print() { //输出员工基本信息
return "姓名:" + name + " 职工号:" + id + " 地址:" + address;
}
public String getName() { //对一些属性员工类型代码Java的设置和修改方法
return name;
}
public void setName(String name) {
this.name = name;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public double getSalary() {
return salary;
}
public void setSalary(double salary) {
this.salary = salary;
}
public static void main(String[] args) {
ZsEmp z = new ZsEmp();
z.setName("正式员工");
z.setId(1001);
z.setAddress("China");
LsEmp l = new LsEmp();
l.setName("临时员工");
l.setId(1002);
l.setAddress("China");
Employee[] emps = new Employee[2];
emps[0] = z;emps[1] = l;
for(Employee e : emps){
System.out.println(e.print()+"员工类型代码Java,他的工资:"+e.js());
}
}
}
class ZsEmp extends Employee{ //正式员工
@Override
public double js() {
double s = 3000; //不知道具体的计算方法是怎样员工类型代码Java,这里简单写了
return s;
}
}
class LsEmp extends Employee{ //临时员工
@Override
public double js() {
double s = 1000;
return s;
}
}
Q2: 用java编写员工类Employee
public class Employee {
private int id;
private byte sex;
private String name;
private String duty;
private float salary;
private int holidays;
public Employee(int id,byte sex,String name,String duty, float salary,int holidays){
this.id = id;
this.sex = sex;
this.name = name;
this.duty = duty;
this.salary = salary;
this.holidays = holidays;
}
public String getDuty() {
return duty;
}
public void setDuty(String duty) {
this.duty = duty;
}
public int getHolidays() {
return holidays;
}
public void setHolidays(int holidays) {
this.holidays = holidays;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public float getSalary() {
return salary;
}
public void setSalary(float salary) {
this.salary = salary;
}
public byte getSex() {
return sex;
}
public void setSex(byte sex) {
this.sex = sex;
}
/**
* display()员工类型代码Java,无返回值,该方法能打印员工的姓名、性别以及职务
* @param employee
*/
public void display(Employee employee){
System.out.println("员工姓名为: " + employee.getName());
if(employee.getSex()==1){
System.out.println("员工性别为: 男 ");
}else if(employee.getSex()==2){
System.out.println("员工性别为:女 ");
}
System.out.println("员工职务为: " + employee.getDuty());
}
/**
* getDecMoney(int day) 返回值是int型。
* 如果请假天数=3,则扣款为30×请假天数员工类型代码Java;
* 如果请假天数超过3天,则扣款为50×请假天数。
* @param day
* @return
*/
public int getDecMoney(int day){
int deduction = 0; //扣除的工资
if(day = 3){
deduction = 30*day;
}else if(day 3){
deduction = 50*day;
}
return deduction;
}
public static void main(String[] args){
//创建一个员工类的对象
Employee employee = new Employee(123456789,(byte) 1,"陈冠希","生产帽子的(绿色)",(float) 500.8,5);
employee.display(employee); //调用display()
int deduction = employee.getDecMoney(employee.getHolidays());//调用getDecMoney()
System.out.println("该员工因请假扣除工资" + deduction + "元");
}
}
Q3: java,编写某公司三种类型员工:
package com.lw.thread;
/*
* 每个员工都是人吧,都有自己的名字,年龄,和最后核发的工资熟悉
* 是父类吧
*/
public class People {
private String name;
private int age;
private double 最后总工资;
public double get最后总工资() {
return 最后总工资;
}
public void set最后总工资(double 最后总工资) {
this.最后总工资 = 最后总工资;
}
public static void main(String[] args) {
// 这一句就是多态了,公司的员工=new公司的某个员工,
People XXX = new 文员(10000, 20000, 1.5);
System.out.println(XXX.get最后总工资());
}
}
/*
* 有个文员职位的员工,因为他计算工资的方式不同,所以我们的给他设这些属性 最后计算自己的工资
* 此处写了一个,另外2个自己会了吧。
*
* ↖(^ω^)↗!
*/
class 文员 extends People {
private double 基本工资;
private double 资金;
private double 缺勤天数;
public 文员(double 基本工资, double 资金, double 缺勤天数) {
super();
this.基本工资 = 基本工资;
this.资金 = 资金;
this.缺勤天数 = 缺勤天数;
super.set最后总工资(基本工资 + 资金 - 缺勤天数 * 5);
}
}
员工类型代码Java的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于员工类型编码、员工类型代码Java的信息别忘了在本站进行查找喔。







