For this assignment you will be creating a class definition for
a Contact, like one that you would add to your phone. Each Contact
will have a first name, last name, phone number, and email. Within the
class definition, there will be an accessor and mutator function for each
member variable. Also, inputContact and displayContact. Main will behave
like the previous homework assignment, which will be a menu based program
that will display options to add a new contact, display all contacts, search
for a contact by first name, and exit.
Contact
Member Variables
cstring member variables for first name, last name, phone number, and
email. Each of these member variables will be private and have a static
size of 32.
public member functions
Each member function will be declared (prototype) within the class
definition and defined outside the class definition
(scopeResolution::operator)
bool setFirstName - this function will pass in a const cstring and
assign the passed parameter to the first name member variable and return
true
bool setLastName - this function will pass in a const cstring and
assign the passed parameter to the last name member variable and return
true
bool setPhoneNumber - this function will pass in a const cstring
and assign the passed parameter to the phone number member variable and
return true
bool setEmail - this function will pass in a const cstring and assign
the passed parameter to the email member variable and return true
const char* getFirstName const - this function will return the cstring member
variable first name
const char* getLastName const - this function will return the cstring member
variable last name
const char* getPhoneNumber const - this function will return the cstring member
variable phone number
const char* getEmail const - this function will return the cstring member
variable email
void inputContact - this function will create a cstring called temp
with static size 32. For each member variable, prompt the user for input
and call the corresponding mutator function passing the temp cstring
void displayContact - this function will print each member variable
of the Contact calling the corresponding accessor function.
Default Constructor
The default constructor will initialize the each cstring member
variable to an empty string. The definition will be outside the class
definition
Destructor
The destructor will assign '\0' to the first subscript of each
member variable. The definition will be outside the class definition
Global Functions
void addContact - this function will pass an array of Contact Objects
and an integer by reference for the current count of Contact Objects within
the array. This function will call inputContact member function for the
array at index count. Increment count then return.
void displayContacts - this function will pass a const array of Contact
Objects and a const integer by value for the current count of Contact
Objects within the array. This function will traverse the array, calling
each objects member function displayContact.
int searchContacts - this function will pass a const array of Contact
Objects and a const integer by value for the current count of Contact Objects
within the array. This function will create a temporary cstring of size 32,
prompt the user for a first name value to search for and input into the
temporary cstring. The function will then traverse array of Contacts
searching for first name that matches the user's input. If a Contact's
first name matches the inputed value, return the index at which the Contact
was found. If there was no match, return -1.
void displayMenu - this function will print the menu with options
to 'Add New Contact', 'Display All Contacts', 'Search Contacts', and 'Exit'