



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




For Loop ✔✔for(var i = 0; i < COUNT; i++){ } While Loop ✔✔while(boolean expression){ /* Repeat code betweeen brackets while
Functions ✔✔/ Functions can take in values, called parameters. // The function below takes in a parameter called // 'input' and prints it. function printText(input) { println(input); } Functions using return ✔✔function addTwo(number) { return number + 2; } Returns the width of the canvas ✔✔getWidth(); Returns the height of the canvas ✔✔getHeight(); Returns the x coordinate of the center of the canvas ✔✔getWidth() / 2;
Add objects to your screen ✔✔add(obj); Get location of the upper left corner of the rectangle ✔✔var x = rect.getX(); var y = rect.getY(); Create an Arc ✔✔var myArc = new Arc(radius, start, end, unit); More specifically, the parameters are:
Set the line width to 10 pixels line.setLineWidth(10); Create an oval ✔✔var oval = new Oval(width, height); oval.setPosition(x, y); oval.setColor(color) Create a graphical text object ✔✔var txt = new Text(label, font); txt.setPosition(x, y); txt.setColor(Color.blue); Comparison Operators ✔✔x == y // is x equal to y x != y // is x not equal to y x > y // is x greater than y x >= y // is x greater than or equal to y x < y // is x less than y x <= y // is x less than or equal to y
Read a boolean ✔✔var bool = readBoolean(prompt); Declare a variable ✔✔var myVarName; Initialize a variable ✔✔var myVarName = 5; Assign to an existing variable ✔✔myVarName = 10; Increment (add one) ✔✔x++ Decrement (subtract one) ✔✔x--