/* Holds the contact information
* a simple class that hold an individual's contact information including
* their name, address, phone number, and website address.
*/
class Addr
{
/* All internal names have a get and set method */
/* the persons name
* @visibe private
* @type string
*/
private string name
{
get { return name; }
set { name = value; }
}
/* the person's address
* @visibe private
* @type string
*/
private string address
{
get { return address; }
set { name = value; }
}
/* The person's phone number
* @visibe private
* @type string
*/
private string phone
{
get { return phone; }
set { phone = value; }
}
/* the person's website url
* @visibe private
* @type string
*/
private string website
{
get { return website; }
set { website = value; }
}
/* constructor
* name, address, phone and website provided for the constructor. Overloaded
*
* @param string name
* @param string address
* @param string phone
* @param string website
* @visible public
*/
public Addr(string name, string address, string phone, string website) {}
public Addr(string name, string address, string phone) :this(name, address, phone, "") {}
public Addr(string name, string address) : this(name, address, "", "") {}
public Addr(string name) :this(name, "", "", "")
{
this.name = name;
this.address = address;
this.phone = phone;
this.website = website;
}
/* holds the various Addr objects
* a collection of the various Addr objects in one easy to use book. You can add,
* delete, modify, and retreive individual addresses as well as all of them at once.
*/
class AddrBook : ArrayList
{
/* var to hold the collection of Addr
*
* @visible private
* @type ArrayList
*/
private ArrayList book;
....
public string findOne(string name)
{
int? index = this._search(name);
if (index != null)
{
return book[index].ToString();
}
else
{
return null;
}
}
.....
public override string ToString()
{
return base.ToString();
}
}