class DemoEmployee {
public static void main(String[] args) {
Employee e1 =new Employee();
e1.setName("张三");
e1.setId(100100);
e1.setSalary(18000);
System.out.println("姓名:"+e1.getName()+",卡号:"+e1.getId()+",薪水:"+e1.getSalary());
Employee e2 = new Employee("李四",100220,19000);
e2.work();
}
}
class Employee {
private String name;
private int id;
private int salary;
public Employee() {
}
public Employee(String name,int id,int salary) {
this.name = name;
this.id = id;
this.salary = salary;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setId(int id) {
this.id = id;
}
public int getId() {
return id;
}
public void setSalary(int salary) {
this.salary = salary;
}
public int getSalary() {
return salary;
}
public void work() {
System.out.println(name + "..."+id+"..."+salary);
}
} |
|