1.打印个人信息,实现中英文切换
代码实现:
class Person{
private final String name;
private String post;
private final boolean sex;
private int age;
private String tel;
private String adress;
public Person(String name,boolean sex){
this.name = name;
this.sex = sex;
}
public String getName(){
return this.name;
}
public boolean getSex(){
return this.sex;
}
public void setPost(String post){
this.post = post;
}
public String getPost(){
return this.post;
}
public void setAge(int age){
if(age>=0 && age <=120){
this.age= age;
}else{
this.age= 0;
}
}
public int getAge(){
return this.age;
}
public String getTel(){
return this.tel;
}
public void setTel(String tel){
this.tel= tel;
}
public String getAdress(){
return this.adress;
}
public void setAdress(String adress){
this.adress= adress;
}
public void print(String name,String post,boolean sex,int age,String tel,String adress){
System.out.print("Name:" +name+"\t");
System.out.println("Post:" +post+"\t");
if(sex == false){
System.out.print("Sex:female" +"\t");
}else{
System.out.print("Sex:male