Week of February 7, 2016
Topics for this week: Methods
||Read chapter 6 in your course packet.
||Review the slides Methods
||Watch the video on How Methods Work
||Study the sample code here
that demonstrates the use of methods.
lab #10, due by 11:59pm on Tuesday.
lab #11, due by 11:59pm on Thursday.
project #4, due by 11:59pm on Sunday.
||Take the exam, it is available through Wednesday.|
It is expected that you will meet the objectives outlined here by the end of the week.
You might want to test yourself to see how well you fare. You can be guaranteed that you
will be tested on these concepts on your next exam. By the end of this unit, you should
be able to:
- Correctly use predefined methods built into the .Net Library.
- Correctly use the Math built in methods, in particular Sqrt, Ceil, Floor, and Pow.
- Describe the difference between a void method and a method that returns a value.
- Identify code that should be written as a method.
- Create programmer defined functions that work correctly.
- Describe the use of pre-conditions and post-conditions in methods, and properly document pre- and post-conditions in method prologues.
- Write code that correctly calls a function.
- Explain C#s scope rules.
- Correctly use local,global, and static variables in a program.
- Use stepwise refinement to solve a computing problem.
- Chapter 10 in the course packet introduces the concept of a method and how to use methods to solve
- The slides on "Methods" cover this material in more detail.
You should be sure that you understand the following important ideas about methods:
- Methods are basic building blocks of a program. They allow us to break
our programs into small, meaningful pieces, where each piece has a well defined operation
that it performs. A well written method should just do one task, but do it completely.
- The .Net library provides a large number of pre-defined methods that do common
mathematical operations, such as finding the square root of a number.
- A method prologue is a set of comment lines that explain what a method
is for and how it should be used. Pre-conditions in the method prologue are conditions
that parameters passed to the method must meet in order for the method to
- A variable's scope defines where in the program that variable can be seen from.
- A variable's lifetime defines when a variable comes into being and when
it ceases to exist.
This week you should complete labs 10 and 11. These labs introduce methods and explain how to
use stepwise refinement to solve a problem.