Question: Figure 4.4 describes a model [39] for a Contact system. ContactList can derive from or reuse any Qt container that you like, as long as

 Figure 4.4 describes a model[39] for a Contact system. ContactList can

Figure 4.4 describes a model[39] for a Contact system. ContactList can derive from or reuse any Qt container that you like, as long as it supports the operations listed.

getPhoneList(int category) accepts a value to be compared with a Contact's category member for selection purposes. It returns a QStringList containing, for each selected Contact, the name and phone number, separated by the tab symbol: "\t".

getMailingList() has a similar selection mechanism and returns a QStringList containing address label data.

Write a ContactFactory class that generates random Contact objects. Example 4.4 contains a substantial hint.

Example 4.4. src/containers/contact/testdriver.cpp

[ . . . . ] void createRandomContacts(ContactList& cl, int n=10) { static ContactFactory cf; for (int i=0; i> cl; derive from or reuse any Qt container that you like, as long } } 

as it supports the operations listed. getPhoneList(int category) accepts a value to

Adds a Contact into the ContactList.

There are many ways to generate random names/addresses. One way is to have the ContactFactorycreate lists of typical first names, last names, street names, city names, and so forth.[40] When it is time to generate a Contact, it can pick a random element from each list, add randomly generated address numbers, zip codes, etc. We demonstrate the use of the random() function in Section 1.13.3

Write client code to test your classes. In particular, the client code should generate some random contacts. After that, it should test the two query methods (getPhoneList() and getMailingList()) to ensure that they return the proper sublists. Print the original list and the query results to standard output. Summarize the results by listing the number of elements in the original ContactList compared to the query results.

Contact ContactList category :int firstName QString lastName QString streetAddress : QString zipCode QString city: QString -phoneNumber QString +toString:QString + add(c : Contact) + remove(c : Contact) +getPhoneList(category : int) : QStringList + getMailingList(category : int): QStringList QtContainerClass Contact ContactList category :int firstName QString lastName QString streetAddress : QString zipCode QString city: QString -phoneNumber QString +toString:QString + add(c : Contact) + remove(c : Contact) +getPhoneList(category : int) : QStringList + getMailingList(category : int): QStringList QtContainerClass

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!