Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Language: C++ pet code that should be modified: Thank you so much for the help! :) For this lab you will be modifying the pet
Language: C++
pet code that should be modified:
Thank you so much for the help! :)
For this lab you will be modifying the pet program from the textbook. Pay careful attention to how the data and the functions in the pet object are accessed. The dot notation being used is very similar to the notation used in structures (e.g. player1.health). .Add more interactive output text when the user plays with their pet (similar to the "MMM Yummy" message when a pet is fed) Longer Pet Names. Currently, a pet's name can only consist of a single word (e.g., "Bob" or "Fluffy"). This is because the input operator>>reads characters only up to the next whitespace. If the user enters a name like "Bob P. Fluffles," only the "Bob is read-the rest of the name remains in the input buffer and causes problems later in the program The string class has a number of functions that can solve this problem. The simplest is getline(cin, string) which reads a string of characters up to a newline character (n') from the istream argument (cin) and stores them in the string argument. Use this function to allow pets to have longer, multipart, names. (An alternative approach would be to declare several new data members as part of the pet class: first name, last name etc. But it's trickier to get this to work smoothly if the pet's name has a variable numbers of parts: first, last, middle, title, etc.) . . Change the feed member function so that the player has several options of what to feed their pet. For example, treats, which increase happiness, but don't effect hungry much, or normal food, which lowers hunger, but doesn't affect happiness much. Give pets a species type. Add a new data member that stores the type or species of the pet. The new data member should be of type string like the name data member. The new data member should be added around lines 7-9, where the other data members are declared. In addition, the user will need to enter the type of the pet as part of the constructor member function (ines 2b-7b) and the print)member function should print each pet's type (around line 34b)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started