SOLUTIONS
Methods - ANSWERcan be used to break a complex program into small manageable
pieces
divide and conquer - ANSWERprocess of breaking down a complex program into small
manageable pieces
modularization - ANSWERbreaking down a program into smaller units of code such as
methods
void, value returning - ANSWERtwo types of methods
void method - ANSWERsimply executes a group of statements then terminates
value-returning method - ANSWERmethod returns a value to the statement that called it
using a long sequence of statements to perform a task - ANSWERNamespace Example
{
public partial class Form1 : Form
{
private void myButton_Click(object sender, EventArgs e)
{
statement;
statement;
statement;
statement;
statement;
statement;
...
}
}
}
using methods to divide and conquer a problem - ANSWERNamespace Example
{
public partial class Form1 : Form
{
private void myButton_Click(object sender, EventArgs e)
{
Method2();
Method3();
...
,}
private void Method2();
{
statements;
}
private void Method3();
{
statements;
}
}
}
write its definitions in two parts - ANSWERhow to create a method
header and body - ANSWER2 parts of a method
header - ANSWERpart of a method that appears at the beginning of a method definition
to indicate access mode, return type, and method name
body - ANSWERpart of a method that is a collections of statements that are performed
when the method is executed
access modifier, return type, method name, parentheses - ANSWERfour parts of a
method header
access modifier - ANSWERkeywords that define the access control
private access modifier - ANSWERcan only be called by code inside the same class as
the method
public access modifier - ANSWERcan be called by a code that is outside the class
return type - ANSWERspecifies whether or not a method returns a value
method name - ANSWERthe identifier of the method, must be unique in a given
program
parantheses - ANSWERalways follows a methods name
a method header to display a message box - ANSWERprivate void DisplayMessage()
{
MessageBox.Show("This is the DisplayMessage method.");
}
a class - ANSWERa method usually belongs to what
, method call statement - ANSWERthe name of a method followed by a pair of
parenthesis
ex of calling a method - ANSWERprivate void goButton_Click(object sender, EventArgs
e)
{
MessageBox.Show("This is the goButton_Click method.");
DisplayMessage();
}
private DisplayMessage()
{
MessageBox.Show("This is the DisplayMessage method.");
}
return point - ANSWERthe address of the location to which the system should return to
after the method ends
top-down design - ANSWERtechnique used to modularize a program, breaks down an
algorithim into mehtods
argument - ANSWERany piece of data that is passed into a method when the method is
called
parameter - ANSWERa variable that receives an argument that is passed into a method
ex of parameter - ANSWERprivate void DisplayValue(int value)
{
MessageBox.Show(value.ToString());
}
ex of passing a variable as an argument - ANSWERint x = 5;
DisplayValue(x);
DisplayValue(x * 4);
private void DisplayValue(int value)
{
MessageBox.Show(value.ToString());
}
- You can pass only string arguments into string parameters
- You can pass int arguments into int parameters, but you
cannot pass double or decimal arguments into int parameters
- You can pass either double or int arguments to double
parameters, but you cannot pass decimal values to double
parameters
- You can pass either decimal or int arguments to decimal