Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

can I get help writing this in C++ following these guidelines

Executes without crashing

Appropriate Internal Documentation

Pet Class

     Data members: name, type, weight

     Constructor/destructor

     Getters/setters as appropriate

Main:  The following items must be implemented in main() or by functions called from main()   They must not be implemented in the Pet class

     Prompts user for the number of pets

     Creates the pet array using dynamic memory allocation

     Dynamically creates a pet object

     Generates a random weight (between 1-100 inclusive) for each pet

     Seed is 100

     Prints contents of array as illustrated in diagram

     De-allocates memory (both the array and the contents of the array) before exiting

Style:

     Modular design, no global variables, etc.

AutoSave O Off
CSIS112_C_Plus_Plus_Programming_Assignments_Instructions(1) - Protected View - Saved to this PC -
A Steven Brightwell
O X
SB
File
Home
Insert
Draw
Design
Layout
References
Mailings
Review
View
Help
PDFelement
3 Share
P Comments
PROTECTED VIEW Be careful-files from the Internet can contain viruses. Unless you need to edit, it's safer to stay in Protected View.
Enable Editing
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
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
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
Pet type:
Pet weight:
16
In the pet destructor
In the pet destructor
In the pet destructor
Press any key to continue .
Page 26 of 38
9623 words
D Focus
Text Predictions: On
90%
expand button
Transcribed Image Text:AutoSave O Off CSIS112_C_Plus_Plus_Programming_Assignments_Instructions(1) - Protected View - Saved to this PC - A Steven Brightwell O X SB File Home Insert Draw Design Layout References Mailings Review View Help PDFelement 3 Share P Comments PROTECTED VIEW Be careful-files from the Internet can contain viruses. Unless you need to edit, it's safer to stay in Protected View. Enable Editing 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 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 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 Pet type: Pet weight: 16 In the pet destructor In the pet destructor In the pet destructor Press any key to continue . Page 26 of 38 9623 words D Focus Text Predictions: On 90%
AutoSave O Off
CSIS112 C_Plus_Plus_Programming_Assignments_Instructions(1) - Protected View - Saved to this PC -
A Steven Brightwell
O X
SB
File
Home
Insert
Draw
Design
Layout
References
Mailings
Review
View
Help
PDFelement
3 Share
P Comments
PROTECTED VIEW Be careful-files from the Internet can contain viruses. Unless you need to edit, it's safer to stay in Protected View.
Enable Editing
Write a class called Pet that contains an animal's name, type, and weight. Include a default
constructor and destructor for the class. The constructor should print out the following message:
"Creating a new pet". The destructor should print out the following message: "In the Pet
destructor." Include appropriate get/set functions for the class.
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.
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.
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:
Page 25 of 38
9623 words
Text Predictions: On
D'Focus
100%
4:27 AM
O Type here to search
ENG
03/01/2021
expand button
Transcribed Image Text:AutoSave O Off CSIS112 C_Plus_Plus_Programming_Assignments_Instructions(1) - Protected View - Saved to this PC - A Steven Brightwell O X SB File Home Insert Draw Design Layout References Mailings Review View Help PDFelement 3 Share P Comments PROTECTED VIEW Be careful-files from the Internet can contain viruses. Unless you need to edit, it's safer to stay in Protected View. Enable Editing Write a class called Pet that contains an animal's name, type, and weight. Include a default constructor and destructor for the class. The constructor should print out the following message: "Creating a new pet". The destructor should print out the following message: "In the Pet destructor." Include appropriate get/set functions for the class. 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. 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. 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: Page 25 of 38 9623 words Text Predictions: On D'Focus 100% 4:27 AM O Type here to search ENG 03/01/2021
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education