Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ language c++ language Write a driver program to test the class you have implemented, where you will: 1. Create an array of strings named

c++ language image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
c++ language
Write a driver program to test the class you have implemented, where you will: 1. Create an array of strings named my_entries of size 10 and fill it from the user. 2. Create a Directory object named Di with maxSize 10 and fill the first 4 entries in its list using the values from my_entries array. 3. Print the index of the entries in Di with same name in the entries as the last entry name from my_entries array. 4. Remove the second entry from list in D1 (use Erase function). 5. Print the utilization of the Di. 6. Display the details of D1. 7. Write the code to ask the user of how many Directory objects he/she want to create, then create an array of Directory based on his input. Each Directory contains a number of entries; Implement class Directory with the following: 1. Three private data member: (6 points) a int maxSize b. int current to track the current number of entries in the Directory. This attribute gets modified whenever an entry is inserted or removed from list. c. string *list a pointer a dynamic array of strings that represent the names of the contacts in the entries. 2. The following public member functions: (54 points): Use this pointer in all member function of the class that take one or more parameters, a. Defaulted parameterized constructor that receive only one integer parameter for the maxSize data member.it set the current data member to zero, create and fill the list with "N/A". The Default value of maxSize is 10. b. Deep Copy Constructor. Directoryo: Deallocate the list. disEmpty(), a boolean function that returns true if current == 0 and false otherwise. c. isFullo), a boolean function that retums true if current - maxSize, and false otherwise. c. Directory0: Deallocate the list. disEmpty0, a boolean function that returns true if current = = 0. and false otherwise. c. isFullo, a boolean function that returns true if current==maxSize, and false otherwise. fint find(string entry) returns the index of entry if found in list, otherwise returns -1. g. void insert(string entryname) this function does the following: 1. Inserts entryname into the end of the list in the Directory, if both: the Directory is not full and entryname does not exist in list. 11. If entryname to be inserted is already in list, then print a message saying the entry won't be inserted because it already exists in list. 111. If entryname is not in list, but list is full, then print a suitable message to say that the insert operation failed h. void printDirectory(): prints the names of the contacts in the entries currently in the Directory alongside their number index). I 1. Setter and getter for maxSize. 3. getter for current data member k. float utilization() that calculates the percentage of used entries in a Directory. (hint: utilization is 100*current/maxSize). Make sure that the division is a floating-point division. 1. make all the member functions that do not change or modify data constant. 3. Define friend function void Erase(Directory& obj, int i): if the Directory is not empty and if the index (i) is between 0 and current-1, inclusive, it removes the ih entry from list in Directory and shifts remaining entries to left to fill the gap. Otherwise, it prints a message that indicate if the Directory is empty or the index (i) is out of range

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Case Studies In Business Data Bases

Authors: James Bradley

1st Edition

0030141346, 978-0030141348

More Books

Students also viewed these Databases questions