Method Comments

Line: Loopy Line
Medium Difficulty Methods Learning Outcome One Learning Outcome Three Learning Outcome FourLearning Outcome Six Exercise
Type: Exercise
You should have completed:

Geometry Calculations

This topic leads to:

Recursion

Summary

Methods package up parts of your programs into separate functions that can be run repeatedly from other parts of your code, or just used to simplify the main program and make it easier to read.

In this exercise you will see how to comment your methods easily and effectively

Task

  1. Open your application from Geometry Calculations
  2. In the line above the declaration of your box volume calculation method type three slashes (///)
  3. Notice how a template method comment is automatically generated for you, including places to describe what the method does (summary) what the parameters are for (param) and what the return value means (returns)
  4. Fill in this template with a meaningful description for each element, then save the file.
  5. Find where you call this method in your code and hover the mouse cursor over the name of the method. Notice how that information is now available on the tooltip.
  6. Delete the line where you call the method and type it out again. Notice how as you type, the information about each parameter is displayed to you as you go.
  7. Finally, add method comments to all the methods in you program.