csci 20 :: book learning challenge 8 (due tues, mar 22)
Submitting your work: Complete this exercise on your own.

Fill in all of the "Answer" boxes, then print the answer grid that you see after you press "Prepare for printing".

Staple all pages together and submit to the instructor on the date listed above.

Questions:

Read and answer the following (all questions refer to the class defined in Container.hpp):

Your name:
  1. What is the name of the class being defined in Container.hpp?
    Answer:
  2. Write the C++ code to declare two (2) objects of the class type defined in Container.hpp -- name one object waterTank and the other object shippingContainer.
    Answer:
  3. Write the C++ code to do the following (using the waterTank object declared in the previous question):
    • set the containerType to 'C'
    • set the description to "water tank"
    • set the radius to 36.0
    • set the height to 65.0

    Answer:
  4. Write the C++ code to do the following (using the shippingContainer object declared in the previous question):
    • set the containerType to 'B'
    • set the description to "shipping container"
    • set the height to 8.0
    • set the length to 20.0
    • set the width to 8.0

    Answer:
  5. Write the C++ code to do the following:
    • declare a double variable named tankVolume and assign it the value of the computed volume of waterTank
    • declare a double variable named ContainerVolume and assign it the value of the computed volume of shippingContainer

    Answer:
  6. Write the C++ code for the following function (this function would be inserted into the class defined in Container.hpp):
    • function: getVolume
    • return type: double
    • if containerType is 'C', return volume of a cylinder
    • else if containerType is 'B', return volume of a box
    • else return 0.0

    Answer:
  7. Write the C++ code to (1) display the volume of waterTank and (2) display the volume of shippingContainer, each in a single line of code.
    Answer:
  8. Write the C++ code for the following mutator/setter function (this function would be inserted into the class defined in Container.hpp):
    • function: setDescription
    • return type: void
    • parameter: newDescription (string)
    • assigns the value of newDescription to description

    Answer:
  9. Write the C++ code for the following accessor/getter function (this function would be inserted into the class defined in Container.hpp):
    • function: getDescription
    • return type: string
    • returns description

    Answer:
  10. Write the C++ code to do the following:
    • use setDescription to change the description of waterTank to be "plastic water tank"
    • use setDescription to change the description of shippingContainer to be "intermodal shipping container"
    • use getDescription to display the description of waterTank
    • use getDescription to display the description of shippingContainer

    Answer:

Total points for this book learning challenge:

150 points