public class Test {
public static void main(String[] args) {
Employee em = new Employee(121203, "liko梵梵醬 ", 20, true, "123456789");
System.out.println("性別:"+em.getSex()+",年齡"+em.getAge()+",聯系方式"+em.getPhone());
}
}
Employee類
public class Employee {
long id;
String name;
int age ;
boolean sex;//true:女 false:男
String phone;
Employee(){}
Employee(long id, String name, int age, boolean sex, String phone){
this.id = id;
this.name = name;
this.age = age;
this.sex = sex;
this.phone =phone;
}
public int getAge(){
return this.age;
}
public String getSex(){
if(this.sex)return "女";
return "男";
}
public String getPhone(){
return this.phone;
}
}