In Class Lab

Exploring Classes

(Example from Malik book: Chapter 12, #12, modified)

 

Write a definition of a class that has the following properties.

a.       The name of the class is secretType.

b.       The class secretType has four member variable:  name (a string), age and weight (int), height (double)

c.        The class secretType has the following member functions: (Make the accessor functions const)

                         i.          print – outputs the data in the member variables in a nice format

                        ii.          setName – sets the name

                      iii.          setAge – sets the age

                      iv.          setWeight – sets the weight

                       v.          setHeight – sets the height

                      vi.          getName – value returning function returns the name

                    vii.          getAge – value returning function returns the height

                   viii.          getWeight – value returning function returns the weight

                      ix.          weightStatus – value returning function that returns  a string according to the following chart (taken from: http://www.whathealth.com/bmi/formula.html  You can find the formula for BMI (body mass index) at that same site):

 

BMI

Weight Status

Below 18.5

Underweight

18.5 -24.9

Normal

25 - 29.9

Overweight

30 & Above

Obese

 

d.       Write definitions of all the member functions of class secretType.