Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write a class for bunny including a private name variable. Using the constructor to initialize the name. Define a public print() method to output the

write a class for bunny including a private name variable. Using the constructor to initialize the name. Define a public print() method to output the name variable in format "Bunny name: ***". (*** is the value of name member variable).

Write the main program to first include and declare a vector of element type of pointer of bunny class object.

Then, in the first loop, use new to allocate and create 3 bunny objects (so loop for three times), taking user input for the name and using the contructor to intialize each time of the loop. Push the pointers (NOT the objects themselves) from allocation into the vector.

In the second loop, call print() through each bunny's pointer in the vector.

In the third loop, delete the bunny objects by the pointers in the vectors.

Code guidelines:

  • Good style:Use proper indentation,no magic numbers,good naming conventions.
  • Usability:Always prompt the user for input so they know what to do and provide meaningful output messages.
  • Input Validation:The program should not accept invalid input, prompt the user to reenter an input that is invalid.
  • Documentation:Add a comments that document what each part of your code does, at a minimum each function should be clearly documented by describing the expected argument values and what the function returns.
  • Testing:Make sure your code compiles and works

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

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions