//get***方法和set***方法
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 int getage(){
return age;
}
public void setage(int age){
this.age=age;
}
public String getzhiye(){
return zhiye;
}
public void setzhiye(String zhiye){
this.zhiye=zhiye;
}
public void show(){
System.out.println("编号:"+id+"--"+"姓名"+name+"--"+"年龄:"+age+"--"+"职业"+zhiye);
}
}
public class YuangongTest {
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
yuangong y=new yuangong();
System.out.println("请输入员工的编号");
int id=sc.nextInt();
y.setid(id);
System.out.println("请输入员工的年龄");
int age=sc.nextInt();
y.setage(age);
if(age>=0&&age<=120){
sc = new Scanner(System.in);
System.out.println("请输入员工的名字");
String name=sc.nextLine();
y.setname(name);
sc = new Scanner(System.in);
System.out.println("请输入员工的职业");
String zhiye=sc.nextLine();
y.setzhiye(zhiye);