customer.java

来自「国外的数据结构与算法分析用书」· Java 代码 · 共 35 行

JAVA
35
字号
package People;

import Accounts.Account;
import dslib.list.LinkedListUos;

/**	A bank customer with a list of accounts. */
public class Customer extends Person
{
	/**	A linked list of accounts that belong to this Customer */
	private LinkedListUos accounts;

	/**	Construct a new Customer from a name */
	public Customer(String n)
	{
		super(n);
		accounts = new LinkedListUos();
	}

	/**	Add the specified Account to the linked list of accounts */
	public void addAccount(Account a)
	{
		accounts.insert(a);
	}

	/**	Return a string representation of the Customer */
	public String toString()
	{
		String temp = "Name: " + name + "\n";
		accounts.goFirst();
		while (!accounts.after())
			temp += accounts.item().toString();
		return temp;
	}
}

⌨️ 快捷键说明

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