Question: Please write the coding in C++. Please make the coding using the addressbook.cpp, and addressbook.h in the c++ form. Create a class called AddressBook that
Please write the coding in C++. Please make the coding using the addressbook.cpp, and addressbook.h in the c++ form.
Create a class called AddressBook that uses either
-
Java - ArrayList
-
C++ - Vector
in the data section of the class. Since this is a template / generic type you need to make sure that you specify that ArrayList or vector will hold a Person. You should use the Person class you created in Assignment 1. Essentially, we are creating a collection class. In other words, the AddressBook class will be a collection of Person classes.
Constructors
-
AddressBook(); - default constructor. Should have no functionality.
-
AddressBook(string first, string last); - Adds a Person class to the collection and sets address to an empty string
-
AddressBook(string first, string last, string address); - Adds a Person class to the collection.
Mutators
setPerson(string first, string last, string address); - Adds a Person to the collection
Accessors
C++ All accessors will return a pointer to a Person
-
Person *getPerson(); - Returns the next Person in the collection. Each time this function is called it will return the next Person in the list or NULL if the AddressBook is empty. Once you get to the end of the list you should start from element 0 and return the first person.
-
Person *findPerson(string last); - returns the found Person or NULL if Person is not in the AddressBook
-
Person *findPerson(string first, string last); - returns the found Person or NULL of Person is not in the AddressBook
-
void print();- Prints out the entire AddressBook
Java
-
Person getPerson(); - Returns the next Person in the collection. Each time this function is called it will return the next Person in the list or null if the AddressBook is empty. Once you get to the end of the list you should start from element 0 and return the first person.
-
Person findPerson(String last); - returns the found Person or null if Person is not in the AddressBook
-
Person findPerson(string first, string last); - returns the found Person or null if Person is not in the AddressBook
-
void print();- Prints out the entire AddressBook
Note:
You need to use one code path whenever possible. This means you must have delegating constructors. The working constructor can call a function if you wish. In other words, if you have a function that performs a task, you should call it instead of writing duplicate code.
Main
Create functions in main.cpp that will test each of the functions you created. I will leave it up to you as to how to test them but please make sure that I cannot easily force your functions to crash.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
