Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function Definition
- ===================
- OutputType FunctionName(InputType inputName, IntputType intputNameb, ...) {
- statement1;
- statement2;
- ...
- }
- If statement
- ============
- if (condition) {
- statement1;
- statement2;
- ...
- } else {
- ...
- }
- int functionAdd(int a, int b) {
- return a + b;
- ...
- ...
- ...
- }
- Function call
- =============
- int c = functionAdd(5, 3);
- int a = 5;
- if (a >= 4) {
- println("hi");
- } else if (a == 5) {
- println("bye");
- }
- Loops
- =====
- while (condition) {
- ...
- statement1;
- }
- int a = 0;
- while (a < 5) {
- println(a);
- a = a + 1;
- }
- a = 2
- => 0 1 2 3 4
- 1 + 2 + 3 + .... 100
- PVector postion;
- int = 1, 2, 3, 4, 5, -1, -2
- float = 0.2, 0.51234, -1234.24
- bool = true/false
- class Dog {
- int a;
- float b;
- AnotherClass c;
- void sit() {
- ...
- }
- void bark() {
- ..
- }
- }
- ClassName blah = new ...
- blah.a = ?
- class PVector {
- float x;
- float y;
- float z; // member variables
- void add(PVector b) { // member functions
- x = x + b.x;
- y = y + b.y;
- z = z + b.z;
- }
- }
- PVector a = new PVector(1, 2);
- PVector b = new PVector(1, 3);
- a.add(b);
- a == 2, 5
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement