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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

object oriented programming using c++ 

class decleration:

class MyPhoneBook
{
 string* names;
 string* phones;
 int phoneBookSize;

 public:
 MyPhoneBook(int); //Takes size
 MyPhoneBook(const MyPhoneBook&); //Copy Constructor
 bool addEntry(string ,string);
 bool displayEntryAtIndex(int);
 void displayEntryAtIndices(int*);
 void displayAll();
 int* findByName(string);
 int* findByPhone(string);
 bool updateNameAt(string, int);
 bool updatePhoneAt(string, int);
 ~MyPhoneBook();
};

Task:
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.
Transcribed Image Text:Task: 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.
Example:
Parameter array
1
names
Ahmed Sami Adel Maher
Hana Ali
Sally Gamal
Mai Hani
phones
59384926357 29808442454 24551331111 57235667310 84659264782
Output:
Ahmed Sami
Sally Gamal
Mai Hani
59384926357
57235667310
84659264782
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.
Transcribed Image Text:Example: Parameter array 1 names Ahmed Sami Adel Maher Hana Ali Sally Gamal Mai Hani phones 59384926357 29808442454 24551331111 57235667310 84659264782 Output: Ahmed Sami Sally Gamal Mai Hani 59384926357 57235667310 84659264782 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.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education