Variables -Types: String, Float, Integer -Operators: basic math Examples: String name; int score; boolean snowDay; float temperature; ==================================================== == Ifs ========== -Boolean Operators -If Blocks Examples: if(x > 40 && y < 80 || !snowDay) println("worky work"); else if(snowDay) { println("sleep more"); }else if(snowDay || x > 90){ println("win lottery"); } else { println("If nothing else triggered, just do this."); } ==================================================== == Loops ========== -For loops, while loop Examples: for(int i = 0; i < 10; i++){ println("hurray for tests"); } snowDay = false; while (!snowDay) { println("suffer at school"); if(random(10) > 5) snowDay = true; else snowDay = false; } ==================================================== == Arrays ========== -Fixed size arrays, ArrayLists - get. set. -Declarations new ArrayList(); where type = Integer, Float, String etc Examples: Fixed size array int[] scores = new int[20]; scores[8] = 25; scores[2] = 40; scores[19] = 1000; println(scores.length); ArrayList forks = new ArrayList(); forks.add(25); -> .add(value); forks.set(0, 99); -> .set(index, value); forks.get(index); -> returns the value at the index provided forks.size(); -> returns the number of elements in the arraylist ==================================================== == Functions ========== - use inputs - return outputs - return nothing - or require no inputs - Scope for variables Examples: returnType FunctionName(inputs declarations){ //Code! } float getAverage(int num1, int num2, int num3) -> println(getAverage(12,34,67)); void walk(int x, int y) -> walk(200, 300); void contemplate() -> contemplate(); float getAvg(){ float result = 0; for(int i=0; i < scores.length; i++) result += scores[i]; return result / scores.length; } boolean isClick(int x, int y){ boolean result = x > 100 && x < 200 && y > 50 && y < 400; return result; } Usage: float myAvg = getAvg(); if( isClick(355, 800) ){ rect(100,100,400,400); }