How many pets do you have? 3 What is the name of your pet? Buttercup What type of pet is Buttercup? dog Creating a new pet CSIS 112 In main(), prompt the user to enter the number of pets in his or her household. Dynamically create a built-in array based on this number (not a vector or object of the array class) to hold pointers to Pet objects. What is the name of your pet? Charlie what type of pet is Charlie? cat Creating a new pet What is the name of your pet? Porky What type of pet is Porky? pig Creating a new pet Construct a loop in main() that executes once for each of the number of pets that the user indicated. Within this loop, ask the user to enter the name and type of pet. Using a random number generator, generate a weight between 1-100 pounds. Seed this random number generator with 100. Next, dynamically create a Pet object (remember that this requires the use of the "new" keyword which returns a pointer to the location in memory where this pet object was created.) Create each object using the default constructor of the class, and call the set functions to store the name, type, and weight of each pet. Store each Pet pointer in the array. These are the pets you have: Pet name: Buttercup Pet type: Pet weight: dog 66 Pet name: Charlie Pet type: Pet weight: cat 17 Pet name: Porky pig 16 Pet type: Pet weight: In the pet destructor In the pet destructor In the pet destructor Press any key to continue After all of the pet objects have been constructed and added to the array, print out the contents of the array. Because the program uses dynamic memory to store the array as well as the objects in the array, be sure to de-allocate all of the memory before exiting. A sample of the program running is shown below:
How many pets do you have? 3 What is the name of your pet? Buttercup What type of pet is Buttercup? dog Creating a new pet CSIS 112 In main(), prompt the user to enter the number of pets in his or her household. Dynamically create a built-in array based on this number (not a vector or object of the array class) to hold pointers to Pet objects. What is the name of your pet? Charlie what type of pet is Charlie? cat Creating a new pet What is the name of your pet? Porky What type of pet is Porky? pig Creating a new pet Construct a loop in main() that executes once for each of the number of pets that the user indicated. Within this loop, ask the user to enter the name and type of pet. Using a random number generator, generate a weight between 1-100 pounds. Seed this random number generator with 100. Next, dynamically create a Pet object (remember that this requires the use of the "new" keyword which returns a pointer to the location in memory where this pet object was created.) Create each object using the default constructor of the class, and call the set functions to store the name, type, and weight of each pet. Store each Pet pointer in the array. These are the pets you have: Pet name: Buttercup Pet type: Pet weight: dog 66 Pet name: Charlie Pet type: Pet weight: cat 17 Pet name: Porky pig 16 Pet type: Pet weight: In the pet destructor In the pet destructor In the pet destructor Press any key to continue After all of the pet objects have been constructed and added to the array, print out the contents of the array. Because the program uses dynamic memory to store the array as well as the objects in the array, be sure to de-allocate all of the memory before exiting. A sample of the program running is shown below:
Chapter3: Data Representation
Section: Chapter Questions
Problem 3RP
Related questions
Question
Can i get help writing this. It has to use a random number generator plus other requirements. All you need is in the photos
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 4 images
Recommended textbooks for you
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning