小程序求详细的注解
public class Person {
private String name;
private int age;
private boolean sex;
private Person mate;
public boolean mary(Person p){
if(this.isSex()==p.isSex()){
return false;
}
if(this.isSex()){
if(this.getAge()<22||p.getAge()<20)
return false;
}else{
if(this.getAge()<20||p.getAge()<22)
return false;
}
if(this.getMate()!=null||p.getMate()!=null){
return false;
}
this.setMate(p);
p.setMate(this);
return true;
}
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 boolean isSex() {
return sex;
}
public void setSex(boolean sex) {
this.sex = sex;
}
public Person getMate() {
return mate;
}
public void setMate(Person mate) {
this.mate = mate;
}
}