package phonebook;
public class Person {
private int id;
private String name;
private String age;
private String sex;
private String telNum;//会有区号,11位超出了int的长度
private String address;
public Person() {
}
public Person(String name, String age, String sex, String telNum, String address) {
this.name = name;
this.age = age;
this.sex = sex;
this.telNum = telNum;
this.address = address;
}
// alt+insert ----选择 getter and setter
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 String getAge() {
return age;
}
public void setAge(String age) {
this.age = age;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getTelNum() {
return telNum;
}
public void setTelNum(String telNum) {
this.telNum = telNum;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
@Override
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append("序号").append(this.id).append("#").append("\t");
sb.append("姓名").append(this.name).append("\t\t");
sb.append("年龄").append(this.age).append("\t\t");
sb.append("性别").append(this.sex).append("\t\t");
sb.append("电话号码").append(this.telNum).append("\t\t");
sb.append("地址").append(this.address).append("\t\t");
return sb.toString();
}
}
D38 Java智能电话项目本————创建实体类
最新推荐文章于 2024-11-09 12:43:52 发布