bootcamper bootcamper SetUp Docs Reps Blog
bootcamper bootcamper

U3L04 - methods

This lesson drills what Trevor teaches in U3L04

Pre-requirements:

  • You have performed each of previous drills to reach a top speed, and then repeated top speed 10x
  • Follow this for all drills explainer
  • Or this if you haven't even installed the drills yet installation

Summary of what is drilled

A Disciplined Approach? holds that these items should never again allow any confusion in your mind about this list of what Trevor covered in this lesson:

COVERED IN THE LESSON

  • reminder: These concepts transferrable across similar OO languages
  • TIP: MUST MEMORIZE parts to a method include (optional) visibility modifier, return type, methodName, parameter requirements and their type, and scope
  • compiler checks that actual returned is same data type as data type specified
  • to combine Strings into one String, use the + to "concatenate" multiple Strings
  • it is OK to break up a line of code on the + character, for example
  • TIP: MUST MEMORIZE method shown as a way to re-use same block of code instead of copyPasting same code multiple times!!!!! To reduce code duplication.
  • by "extracting" code and placing it inside the scope of a method

Instructor Administered Test

  • Create a new project
  • Create a new package
  • Create a new class with a new public static void main method
  • declare and assign an int variable named wahHoo of 73
  • create the class for Dinosoar with the String properties of weight, color, length
  • from the main method, declare and instantiate a Dinosoar object named oscar
  • from the main method, set the properties of oscar using dot properties
  • create a method named getDetails within Dinosoar that returns a String explaining what the weight, color and length of the dinosoar
  • print the oscar object in the console and observe the details
  • name the primary "win" or motive for creating a method, when instead the details are already available?