java:面向对象练习②-员工类案列练习

版权声明:本文为博主原创文章,未经博主允许不得转载 https://blog.csdn.net/qq_24644517/article/details/82313696
public class Demo07_test02 {
    public static void main(String[]args){
        Employee E1=new Employee();
        E1.setName("员工一号");
        E1.setid("1");
        E1.setSalary(888);
        System.out.println("员工姓名:"+E1.getName());
        System.out.println("员工编号:"+E1.getId());
        System.out.println("员工工资:"+E1.getSalary());

        Employee E2=new Employee("员工二号","2",777);
        System.out.println("员工姓名:"+E2.getName());
        System.out.println("员工编号:"+E2.getId());
        System.out.println("员工工资:"+E2.getSalary());
    }
}

class Employee{
    private  String name;
    private  String id;
    private  double salary;

    public Employee(){
    }

    public Employee(String name,String id,double salary){
        this.name=name;
        this.id=id;
        this.salary=salary;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return this.name;
    }

    public void setid(String id) {
        this.id = id;
    }

    public String getId(){
        return this.id;
    }

    public void setSalary(double salary){
        this.salary=salary;
    }

    public double getSalary() {
        return this.salary;
    }

    public void show(){
        System.out.println("员工姓名"+name);
        System.out.println("员工编号"+id);
        System.out.println("员工工资"+salary);
    }
}

猜你喜欢

转载自blog.csdn.net/qq_24644517/article/details/82313696