// Day 4: // Example: variables, if, if-else // mjh-2013 // initialize program size(600, 450); background(255); textSize(20); fill(0); // basic data types that come with Processing (Java) // these are called "primitive types" int x = 3; // integers float y = 3.145; // decimal numbers (approximations of reals) boolean z = true; // true/false values for logic char c = 'Q'; // a single character inside single quotes // a String is not a primitive type, but is very useful. // We use a string for a collection of characters (i.e., words) String s = "Hello!"; text( "integer x = " + x, 25, 50); text( "float y = " + y, 25, 75); text( "boolean z = " + z, 25, 100); text( "char c = " + c, 25, 125); text( "String s = " + s, 25, 150); // basic branching is done with the "if" statement boolean blueSky = false; if ( blueSky == true ){ text("Hooray, let's go outside and play!", 50, 200); } else{ text("Boo. Let's stay inside and write Processing code!", 50, 200); } blueSky = true; if ( blueSky == true ){ text("Hooray, let's go outside and play!", 50, 225); } else{ text("Boo. Let's stay inside and write Processing code!", 50, 225); } // additon of String. Consider the following... text("some string " + x, 50, 275); // notice the space at the end text("something else " + y, 50, 300); // of the string text(x + " other way around!", 50, 325); // space at the front of stringtext text( 1 + 3 + " is 1 + 3", 50, 350); text("1 + 3 is " + 1 + 3, 50, 375); // make sure you know why text("1 + 3 really is " + (1 + 3), 50, 400); // these are different!