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 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 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 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 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. 5- A function displayAll() that displays all entries in the phone book. 6- A function findByName(string) that search in PhoneBook either by full name or a part of a name and returns an array of int with the same size of PhoneBook. The array is filled with values 0 or 1. Value 0 if name is not a match and 1 otherwise. 7- A 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 match and 1 otherwise. 8- A 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 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.
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
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 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 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 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 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.
5- A function displayAll() that displays all entries in the phone book.
6- A function findByName(string) that search in PhoneBook either by full name or a part
of a name and returns an array of int with the same size of PhoneBook. The array is
filled with values 0 or 1. Value 0 if name is not a match and 1 otherwise.
7- A 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 match and 1
otherwise.
8- A 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 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.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps