當前位置:編程學習大全網 - 編程軟體 - java編程題目 求高手!!!!!!

java編程題目 求高手!!!!!!

測試類(主方法)

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;

}

}

  • 上一篇:過去十年,編程語言領域有什麽重要進展
  • 下一篇:黑峽谷x3怎麽恢復出廠設置
  • copyright 2024編程學習大全網