中易网

用Java编写一个员工类程序:1.属性:员工编号,员工姓名,基本工资,奖金,2.构造方法:至少两个

答案:7  悬赏:30  
解决时间 2021-01-16 12:51
  • 提问者网友:寂寞梧桐
  • 2021-01-15 12:57
用Java编写一个员工类程序:1.属性:员工编号,员工姓名,基本工资,奖金,2.构造方法:至少两个
最佳答案
  • 二级知识专家网友:低血压的长颈鹿
  • 2021-01-15 14:35
public class Worker{
private long number ;

private String name;

//有参构造方法
public Worker(String name){
this.name = name;

}
//无参构造方法
public Worker(){
this.name = “123”;

}

}
全部回答
  • 1楼网友:孤老序
  • 2021-01-15 18:52
无聊的问题
  • 2楼网友:孤老序
  • 2021-01-15 18:32
public  interface Staff{
int num;
String name;
int wage;
int bonus;
public void printStaffInfo{
  
System.oput.printin("员工信息"+"num="+num+"wage="+wage+"bonus="+bonus)}   }
public void inputStaffInfo{ 
}  
 public class StaffA implements Staff{
}
}
//未完 纯手打追问还有么追答按照这个思路来就好了 现在我也不便给你打全
  • 3楼网友:北城痞子
  • 2021-01-15 17:38

用Java编写一个员工类程序:1.属性:员工编号,员工姓名,基本工资,奖金,2.构造方法:至少两个。如下:package com.test;
public class Employee {
    
    private String number;
    
    private String name;
    
    private double salary;
    
    public Employee() {
    }
    
    public Employee(String number, String name, double salary) {
        super();
        this.number = number;
        this.name = name;
        this.salary = salary;
    }
    public static void main(String[] args) {
        //员工一,并且构造函数里设置值
        Employee e1 = new Employee("e0001", "xiaoming", 5000.0);
        System.out.println("员工一:" + e1);
        //员工二,用set设置值,get的话可以获取到员工某个属性
        Employee e2 = new Employee();
        e2.setName("小二");
        e2.setNumber("e0002");
        e2.setSalary(5500.1);
        System.out.println("员工二:" + e2);
    }
    public String getNumber() {
        return number;
    }
    public void setNumber(String number) {
        this.number = number;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public double getSalary() {
        return salary;
    }
    public void setSalary(double salary) {
        this.salary = salary;
    }
    @Override
    public String toString() {
        return "Employee [number=" + number + ", name=" + name + ", salary=" +
        salary + "]";
    }
}
运行结果:
员工一:Employee [number=e0001, name=xiaoming, salary=5000.0]
员工二:Employee [number=e0002, name=小二, salary=5500.1]
  • 4楼网友:西风乍起
  • 2021-01-15 16:39
class emp{
    String id;
    String name;
    int money;
    int money1;
    public emp(){}
    public emp(String id, String name, String money, String money1){
        this.id = id;
        this.name = name;
        this.money = money;
        this.money1 = money1;
    }
}
  • 5楼网友:渡鹤影
  • 2021-01-15 16:33
class 员工{
        //属性
int 员工编号 ;
String 员工姓名 ;
int 基本工资 ;
int 奖金 ;
//两个构造方法
public void 输入(){
}
public void 打印(){
}
}
  • 6楼网友:人间朝暮
  • 2021-01-15 15:26
public class Employee {
public Employee(){
}
public Employee(int id,String name,double bonus,double salary){
this.id=id;
this.name=name;
this.bonus=bonus;
this.salary=salary;
}
public void setInfo(int id,String name,double bonus,double salary){
this.id=id;
this.name=name;
this.bonus=bonus;
this.salary=salary;
}
public void printInfo(){
System.out.println("id:"+id+" name:"+name+" bonus:"+bonus+" salary:"+salary);
}
public double getTotalsalary(){
return bonus+salary;
}
private int id;
private String name;
private double bonus;
private double salary;
}
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息!
大家都在看
推荐信息