C++ "Frog" code programming

computer science

Description

Write a C++ “Frog” class that contains the following (private attributes):

- age (integer): this is the age of the frog in months. It should be initialized to 0.

- length (integer): this is the length of the frog in mm. It should be initialized to 3.

- tadpole (boolean): this is a true/false attribute. Frogs that are less than 3 months are tadpoles.

The public methods (aside from the constructor and destructors) of the class are as follows:

- void eat(): this method adds 1mm to the length of the frog.

- void grow(): this method adds 1 month to the age of the frog.

- void report(): this prints out all the attributes of the frog object. For example, a call to

report() may be printed as follows.

age: 5 months old

length: 5mm

tadpole? No

In your main function, write a test case for the following:

1. Create a new frog

2. Call the report() function

3. Call the eat() function three times

4. Call the report() function

5. Call the grow() function three times

6. Call the report() function


Related Questions in computer science category