展开全部
import java.util.Arrays;
public class AddressBook
{
private int totalContacts; // 现在通讯录中的总数
private int maxContacts; // 通讯录的最大值
private Contact[] contacts; // 通讯录的array
/**
* Constructor. 设定这个通讯录最初的大32313133353236313431303231363533e58685e5aeb931333337626165小为10人上限.
*/
public AddressBook()
{
totalContacts = 0;
maxContacts = 10;
contacts = new Contact[totalContacts];
}
/**
* 得到一个联系通过通讯录中的名字
*
* @param name
* 要去得到的联系人名字
* @return 这个联系人, 没有的话为null
*/
public Contact getContactByName(String name)
{
for(int i = 0; i < totalContacts; i++)
{
Contact c = contacts[i];
if(name.equals(c.getName()))
{
return c;
}
}
return null;
}