每日练习
今天写了一个特别小的代码
package com;
public class Employee {
public String name;
public int age;
public int salary;
public Employee(){
}
public Employee(String name,int age,int salary){
this.name=name;
this.age=age;
this.salary=salary;
}
public void setName(String name){
this.name=name;
}
public String getName(String name){
return name;
}
public void setAge(int age){
this.age=age;
}
public int getAge(int age){
return age;
}
public void setSalary(int salary){
this.salary=salary;
}
public int getSalary(int salary){
return salary;
}
public void printEmployee(){
System.out.println("名字:"+ name );
System.out.println("年龄:" + age );
System.out.println("薪水:" + salary);
}
}
package com;
public class EmployeeTest {
public static void main(String[] args){
Employee e1=new Employee();
e1.setAge(21);
e1.setName("xiaoming");
e1.setSalary(3000);
Employee e2=new Employee("xiaowang",23,5000);
e1.printEmployee();
e2.printEmployee();
}
}
浙公网安备 33010602011771号