Methods

November 4, 2020 ยท View on GitHub

The Concept

A method is a function that is part of a class.

What to cover

  • How to define a method How to define a method. How to add functionality to a method. How does scoping the method work?
  • How to use method parameters How to define method parameters and how to use them.
  • How to return a value from a method How to return a value from a method. Does it require a specific keyword?
  • How to invoke a method How to invoke a method and pass arguments to it.

Exercises

Lasagna cooking

This exercise deals with cooking a lasagna dish in the oven. The reference implementation (C#) teaches:

  • How to define a method with zero, one and two parameters.
  • How to use parameters in a method.
  • How to return a value from a method.
  • How to call a method.

Implementations

TrackExerciseChanges
C#lucians-luscious-lasagnaNone