Conditionals and Introduction to Methods

New Terminology

logical expression
An expression which uses a logical operator. Will evaluate to true or false.
logical operators
&& = AND
|| = OR
! = NOT
constructor
The method which initializes an object as it is created (instantiated) from the class
method
A block of code which can be executed by calling or invoking the code header. May accept parameters and may return a value.
parameters
Values that are passed into a method or function or variables which accept those values.
arguments
Values that are passed into a method
formal parameters
Variables that accept arguments in a method or function
return value
The value that a method returns.

Programming specific structures and terms

nested if
An if/else statement that is inside another if/else structure.
method header
The line that introduces the method.  Includes visibility, method name, return type and formal parameter list.
method declaration
The code that begins with the method header and ends with the final curly brace.
void 
A java keyword that signifies that a method returns nothing.
constructor
The method which initializes an object as it is created (instantiated) from the class

Class notes

  1. Lab Review - DivideBy0.java & BadInput.java
  2. Intro to Logical Operators and Nested ifs - NestedIfLogical.ppt
    1. nested if (cascade) - TestResults.java
    2. nested if (one branch) - LoanQualifier.java
    3. logical AND - LogicalAnd.java
    4. logical OR - LogicalOr.java
    5. comparing characters and Strings - StringCompare.java
  3. Intro to methods
    1. Methods let us divide and conquer the program
    2. Use methods where
      1. You want to reuse the code - see Math class methods
      2. You want to simplify the program - remember we can remember 5-7 things
      3. There are natural divisions of labor in the program
        1. input
        2. output
        3. calculation
    3. Example in BadInputV2. & InputHelper.java