Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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; image text in transcribed } } <>

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions