📄 person.java
字号:
Person.java
public abstract class Person {
//------------
// Attributes.
//------------
private String name;
private String birthday;
private String phone;
//----------------
// Constructor(s).
//----------------
public Person(String name, String birthday,String phone) {
this.setName(name);
this.setBirthday(birthday);
this.setPhone(phone);
}
public Person() {
this.setName("?");
this.setBirthday("????-??-??");
this.setPhone("???????????");
}
//------------------
// Accessor methods.
//------------------
public void setName(String n) {
name = n;
}
public String getName() {
return name;
}
public void setBirthday(String b) {
birthday = b;
}
public String getBirthday() {
return birthday;
}
public void setPhone(String p) {
phone = p;
}
public String getPhone() {
return phone;
}
//-----------------------------
// Miscellaneous other methods.
//-----------------------------
// We'll let each subclass determine how it wishes to be
// represented as a String value.
public abstract String toString();
public void display() {
System.out.println("\tName: " + this.getName());
System.out.println("\tBirthday : " + this.getBirthday());
System.out.println("\tPhone :"+this.getPhone());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -