person.java

来自「类 &#8226 Person:PTS系统中的一个抽象类。 &#8226 C」· Java 代码 · 共 68 行

JAVA
68
字号
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 + =
减小字号Ctrl + -
显示快捷键?