phoneentry.java

来自「ssd3 java编程 exam3 绝对可以」· Java 代码 · 共 94 行

JAVA
94
字号
/**
 * Stores information for one phone entry. The following information
 * is stored:
 * <ol>
 * <li>the name of a person, a <code>String</code>.</li>
 * <li>the fixed telephone of a person, a <code>String</code>.</li>
 * <li>the mobile telephone of a person, a <code>String</code>.</li>
 * </ol>
 *
 * @author  iCarnegie
 * @version  1.0.0
 */
public class PhoneEntry {

	/* Name of the entry */
	private String name;

	/* Fixed telephone of the entry */
	private String fixed;

	/* Mobile telephone of the entry */
	private String mobile;

	/**
	 * Constructs an <code>PhoneEntry</code> object.
	 *
	 * @param initialName  the name of the person.
	 * @param initialFixed   the fixed telephone of the person.
	 * @param initialMobile   the mobile telephone of the person.
	 */
	public PhoneEntry (
		String initialName,
		String initialFixed,
		String initialMobile) {

		this.name = initialName;
		this.fixed = initialFixed;
		this.mobile = initialMobile;
	}

	/**
	 * Obtains the name of this entry.
	 *
	 * @return  the name of this entry.
	 */
	public String  getName()  {

		return  this.name;
	}

	/**
	 * Obtains the fixed telephone number of this entry.
	 *
	 * @return  the fixed telephone number of this entry.
	 */
	public String  getFixed()  {

		return  this.fixed;
	}

	/**
	 * Obtains the mobile telephone number of this entry.
	 *
	 * @return  the mobile telephone number of this entry.
	 */
	public String  getMobile()  {

		return  this.mobile;
	}

	/**
	 * Returns the string representation of this entry in the following
	 * format:  <i>name</i>_<i>F:fixed</i>_<i>M:mobile</i>
	 *
	 * @return  the string representation of this entry.
	 */
	public String toString()  {

		String returnString = getName() + "_F:";
	
		if (getFixed() != null) {
			returnString += getFixed();
		}
		
		returnString += "_M:";

		if (getMobile() != null) {
			returnString += getMobile();
		}

		return returnString;
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?