Implement the following class MyPhoneBook. You can add additional private member variables and functions. The class has the following private member variables: 1- names and phones: Dynamic arrays of...


Implement the following class MyPhoneBook. You can add additional private member


variables and functions.


The class has the following private member variables:


1- names and phones: Dynamic arrays of strings.


2- phoneBookSize: An int that holds size of phonebook.


The Class has the following public/private member functions:


1- Parametrized Constructor that takes the size of PhoneBook and allocate dynamic arrays


of names and phones and a copy constructor to initialize a PhoneBook using another


PhoneBook.


2- A public function addEntry that adds a name and phone number at the first empty space


at corresponding arrays, and returns true if entry is added, false otherwise. An entry is


added if there’s space in the array and if phone number if valid. It checks for the validity


of the phone number by ensuring that it has 11 digits, and doesn’t include any alphabets


or special characters.


3- A public function displayEntryAtIndex(int) that displays a name and phone number at


the specified index. It returns true if the index is in range, false otherwise.


4- A private function displayEntryAtIndices(int*) that receives an array of zeros and ones


and has the same size of the class arrays. The function displays the name and phone


number of an entry in the array only if the corresponding integer in the parameter array


is one.


15:15<br>* ll 12%<br>The Class has the following public/private member functions:<br>1- Parametrized Constructor that takes the size of PhoneBook and allocate dynamic array<br>of names and phones and a copy constructor to initialize a PhoneBook using another<br>PhoneBook.<br>2- A public function addEntry that adds a name and phone number at the first empty spac<br>at corresponding arrays, and returns true if entry is added, false otherwise. An entry is<br>added if there's space in the array and if phone number if valid. It checks for the validi<br>of the phone number by ensuring that it has 11 digits, and doesn't include any alphabet<br>or special characters.<br>3- A public function displayEntryAtIndex(int) that displays a name and phone number at<br>the specified index. It returns true if the index is in<br>4- A private function displayEntryAtIndices(int*) that receives an array of zeros and ones<br>and has the same size of the class arrays. The function displays the name and phone<br>number of an entry in the array only if the corresponding integer in the parameter array<br>is one.<br>range,<br>false otherwise.<br>Example:<br>Parameter array<br>1<br>1<br>1<br>names<br>Ahmed Sami<br>Adel Maher<br>Hana Ali<br>Sally Gamal<br>Mai Hani<br>phones<br>59384926357 29808442454 24551331111 57235667310 84659264782<br>Output:<br>Ahmed Sami<br>59384926357<br>Sally Gamal<br>Mai Hani<br>57235667310<br>84659264782<br>5- A public function displayAll() that displays all entries in the phone book.<br>6- A public function findByName(string) that search in PhoneBook either by full name or<br>part of a name and returns an array of int with the same size of PhoneBook. The array<br>filled with values 0 or 1. Value O if name is not a match and 1 otherwise.<br>7- A public function findByPhone(string) that search in PhoneBook either by full phone<br>number or a part of a phone number and returns an array of int with the same size of<br>PhoneBook, The array is filled with values 0 or 1. Value 0 if phone number not a matc<br>and 1 otherwise.<br>8- A public function updateNameAt(string,int) to update name in PhoneBook at specific<br>index. It returns a bool which is true if the parameter index is within range and name is<br>updated.<br>9- A public function updatePhoneAt(string,int) to update phone number in PhoneBook at<br>specific index. It returns a bool which is true if the parameter index is within range and<br>phone is updated.<br>10-A Destructor to deallocate dynamic arrays and leave no memory leak.<br>

Extracted text: 15:15 * ll 12% The Class has the following public/private member functions: 1- Parametrized Constructor that takes the size of PhoneBook and allocate dynamic array of names and phones and a copy constructor to initialize a PhoneBook using another PhoneBook. 2- A public function addEntry that adds a name and phone number at the first empty spac at corresponding arrays, and returns true if entry is added, false otherwise. An entry is added if there's space in the array and if phone number if valid. It checks for the validi of the phone number by ensuring that it has 11 digits, and doesn't include any alphabet or special characters. 3- A public function displayEntryAtIndex(int) that displays a name and phone number at the specified index. It returns true if the index is in 4- A private function displayEntryAtIndices(int*) that receives an array of zeros and ones and has the same size of the class arrays. The function displays the name and phone number of an entry in the array only if the corresponding integer in the parameter array is one. range, false otherwise. Example: Parameter array 1 1 1 names Ahmed Sami Adel Maher Hana Ali Sally Gamal Mai Hani phones 59384926357 29808442454 24551331111 57235667310 84659264782 Output: Ahmed Sami 59384926357 Sally Gamal Mai Hani 57235667310 84659264782 5- A public function displayAll() that displays all entries in the phone book. 6- A public function findByName(string) that search in PhoneBook either by full name or part of a name and returns an array of int with the same size of PhoneBook. The array filled with values 0 or 1. Value O if name is not a match and 1 otherwise. 7- A public function findByPhone(string) that search in PhoneBook either by full phone number or a part of a phone number and returns an array of int with the same size of PhoneBook, The array is filled with values 0 or 1. Value 0 if phone number not a matc and 1 otherwise. 8- A public function updateNameAt(string,int) to update name in PhoneBook at specific index. It returns a bool which is true if the parameter index is within range and name is updated. 9- A public function updatePhoneAt(string,int) to update phone number in PhoneBook at specific index. It returns a bool which is true if the parameter index is within range and phone is updated. 10-A Destructor to deallocate dynamic arrays and leave no memory leak.
15:16<br>B<br>* ll 12%<br>Class Declaration:<br>class MyPhoneBook<br>{<br>string* names;<br>string* phones;<br>int phoneBookSize;<br>void displayEntryAtIndices(int*);<br>public:<br>MyPhoneBook(int); //Takes size<br>MyPhoneBook(const MyPhoneBook&); //Copy Constructor<br>bool addEntry(string ,string);<br>bool displayEntryAtIndex(int);<br>void displayAll();<br>int* findByName(string);<br>int* findByPhone(string);<br>bool updateNameAt(string, int);<br>bool updatePhoneAt(string, int);<br>-MyPhoneBook();<br>};<br>Note: You can use the built-in function of the C++ string class.<br>Write a suitable main that uses the class members and display a menu as follows:<br>Enter the size of your phone book: 4<br>Enter name 1: Ahmed Sami<br>Enter phone 1: 59384926357<br>Enter name 2: Adel Maher<br>Enter phone 2: 29808442454<br>Enter name 3: Hana Ali<br>Enter phone 3: 24551331111<br>Enter name 4: Sally Gamal<br>Enter phone 4: 57235667310<br>Enter your choice:<br>1- Display all phone book<br>2- Search for entry/entries by name<br>3- Search for entry/entries by phone<br>4- Find an entry by index<br>5- Update name by index<br>6- Update phone by index<br>7- Copy phone book to another and display entries of the new phone bo<br>8- Exit<br>Choice:2<br>The menu takes a choice and loops for choices until the exit option is cho<br>Handle validation of user input by usi Ole Booleans returned by the cl<br>user<br>functions.<br>||<br>

Extracted text: 15:16 B * ll 12% Class Declaration: class MyPhoneBook { string* names; string* phones; int phoneBookSize; void displayEntryAtIndices(int*); public: MyPhoneBook(int); //Takes size MyPhoneBook(const MyPhoneBook&); //Copy Constructor bool addEntry(string ,string); bool displayEntryAtIndex(int); void displayAll(); int* findByName(string); int* findByPhone(string); bool updateNameAt(string, int); bool updatePhoneAt(string, int); -MyPhoneBook(); }; Note: You can use the built-in function of the C++ string class. Write a suitable main that uses the class members and display a menu as follows: Enter the size of your phone book: 4 Enter name 1: Ahmed Sami Enter phone 1: 59384926357 Enter name 2: Adel Maher Enter phone 2: 29808442454 Enter name 3: Hana Ali Enter phone 3: 24551331111 Enter name 4: Sally Gamal Enter phone 4: 57235667310 Enter your choice: 1- Display all phone book 2- Search for entry/entries by name 3- Search for entry/entries by phone 4- Find an entry by index 5- Update name by index 6- Update phone by index 7- Copy phone book to another and display entries of the new phone bo 8- Exit Choice:2 The menu takes a choice and loops for choices until the exit option is cho Handle validation of user input by usi Ole Booleans returned by the cl user functions. ||
Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here