Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

5. Sometimes it can be useful to have a factory class that creates random objects of a particular type so that you can conduct experiments

image text in transcribed
5. Sometimes it can be useful to have a factory class that creates random objects of a particular type so that you can conduct experiments and test various software systems. Typically, the factory class is a friend of the object class. Consider the following UML diagram. [55 points total] Assume that you have access to the files: lastNames.txt, firstNames.txt, streetNames.txt, and cityNaes.txt. Each file has many lines with one name per line. - The CustomerFactory constructor loads the four QStringLists from those files. - createRandomCustomerO calls the four private member functions to obtain data for one Customer. - For example, pickRndStreet() selects a random street name from m _StreetList (e.g., Maple Street). prepends a random address number (e.g., 345), and returns a completed street string (e.g. 345 Maple Street). - createRandomCustomer() then allocates memory, constructs a Customer with that data, and returns a pointer to it. The Customer constructor is private, so only CustomerFactory can use it. - The following client code shows how to use this class to populate a CustomerList. int main0 const int NUMCUSTS =200;// number of Customers needed Customer* custptr: CustomerLis custlst: CustomerFactory custfctry(lastNames. txt, firstNames.txt, streetNames.txt, cityNames.txt); for(int i=0;i

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

Professional Microsoft SQL Server 2012 Administration

Authors: Adam Jorgensen, Steven Wort

1st Edition

1118106881, 9781118106884

More Books

Students also viewed these Databases questions

Question

A chipped cracked sheet of glass is useless to us.

Answered: 1 week ago

Question

Youll receive our usual cheerful prompt service.

Answered: 1 week ago