CSA Unit 1 Guide
Lesson 9: Writing Methods
Video Notes: Writing a Method
Annotate this method using the vocabulary from the video.
(makes a method accessible from anywhere) (indicates no return value)
Public void square()
{ (used to call a method and
pass parameters)
forward();
turnLeft();
forward();
turnLeft(); (the overall code)
forward();
turnLeft();
forward();
turnLeft();
}
Term Definition Example / Picture / Code
the structure of a method that is
method signature
designed by the programmer.
1
CSA Unit 1 Guide
defines and constrains the data
return type type of the value returned from a
subroutine or method
marks the end of a function and
return specifies the value or values to
pass back from the function
Term Definition Example / Picture / Code
a reserved type used mainly to
void specify that a method does not
return any data type.
Reflection
Question of the Day: How do I write methods for the behaviors I want an object to have?
We can write methods by writing “public void methodName()” as our class header in the main Java
file, and define a subclass afterward if we have multiple Java files
What other methods would you want to add to the PainterPlus class?
2
CSA Unit 1 Guide
I would like to add a TurnRight() method, moveAwayFromBlock() method, and turnAround()
method.