For this lab you can work with a partner.
The main aim of this lab is to introduce you to the concept of object interaction, loops, collections like ArrayList, and main method. Make sure you have ArrayList documentation open. You can get it here: http://java.sun.com/j2se/1.5.0/docs/api/
This will help you understand different methods you are using.
This lab is very similar to Lab 5, however we will add one more class, that will be the driver class and implement a main method.
For this lab you will implement three classes: Person, TelephoneBook that will store a collection of Person, and DriverClass that will drive the program.
Class Design
Person
The Person class will have two private fields of type string. The fields are: person's name and his telephone number. Each field needs an accessor and mutator method also known as setters and getters. The class should have two constructors. The signatures are shown below.
Person Class Interface
public Person();
public Person(String name, String Tel);
public void setName(String name);
public void setTel(String Tel);
public String getName();
public String getTel();
TelephoneBook
Your class TelephoneBook will have one private field called telBook of type ArrayList. The signatures for the constructors and methods for this class are specified in the interface along with what they should do.
Note: For each method you will have to figure out from the documentation which method to use from the ArrayList class.
public
TelBook();
public void
addPerson( Person newTel );
public string
showTelephone( int telNumber );
public string
removePerson (String personName);
public void
listTelephones();
The output will be in the following format:
Name: Telephone Number:
The total number of people in the telephone book are : xx
(xx = number of people in the collection. Important: you will count the number of people without using any of arraylist methods.)
DriverClass
This class will have just one method, the main method. I want you to search for the method signature by yourself.
This method will have following functionalities
Create about 5 Person objects
Create an object of type TelephoneBook
Demonstrate usage of all the methods in the TelephoneBook class.
Please document your code.
Absolutely Necessary!