Term Project C++ Pet Class Problem Specification: Design a class named Pet, which should have the following fields: •...

80.2K

Verified Solution

Question

Programming

Term Project C++ Pet Class

Problem Specification:

Design a class named Pet, which should have the followingfields:

• name: The name field holds the name of a pet.

• type: The type field holds the type of animal that a pet is.Example values are “Dog”, “Cat”, and “Bird”.

• age: The age field holds the pet’s age. The Pet class shouldalso have the following methods:

• setName: The setName method stores a value in the namefield.

• setType: The setType method stores a value in the typefield.

• setAge: The setAge method stores a value in the age filed.

• getName: The getName method returns the value of the namefield.

• getType: The getType method returns the value of the typefield.

• getAge: The getAge method returns the value of the agefield.

Once you have designed the class, design a program that createsan object of the class and prompts the user to enter the name,type, and age of his or her pet.

This data should be stored in the object. Use the object’saccessor methods to retrieve the pet’s name, type, and age anddisplay this data on the screen.

Program Output (with Input Shown in Bold): Enter a petname: Lucky Enter a pet type: German Shepherd Enter a pet age: 2The pet name is Lucky The pet type is German Shepherd The pet ageis 2

Answer & Explanation Solved by verified expert
4.1 Ratings (474 Votes)
include includeusing namespace stdclass Petclass defnitionint agestring    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students