Code Review
Warm-up Questions
- What is parameterized design?
- What is conditional design?
-
What are datatypes? Name 3 examples, and explain how you would declare
them in JavaScript (p5) versus Java (Processing)
- What do each of these operators do? &&, ||, +=, ++, %
-
What is the difference between using a single = and == ?
- What are three ways to write "subtract 1 from x" ?
- Draw a sketch of the expected output on screen for the following code.
for (let i = 0; i < 5; i++){
rect(i * 30, height/2, 30, 30);
}
- Why are functions used in coding?
- What is the difference between a class and an object?
- Describe the role of the constructor method.
- When would you need to use a boolean variable
-
Review the following code. What is the value of b after running this
code?
boolean b = false;
b = !b;
-
What will be printed out?
boolean iLoveProgramming = true;
print("It is “+ !(!(iLoveProgramming))) + " that I love
programming!");
- What does the following code print out?
let counter = 1;
let num = 10;
while (counter < num)
{
print(counter);
counter++;
}
- Describe in English words (pseudocode) what this program does.
function setup() {
createCanvas(300, 300);
}
function draw() {
rect(100, 100, 100, 100);
}
function mousePressed() {
if ((mouseX > 100) && (mouseX < 200) && (mouseY > 100) && (mouseY <
200)){
fill(random(0, 255), random(0,255),random(0,255));
} else {
fill(255);
}
}
Code Repair
- Removing Objects from an Array(answer)
- Local vs. Global Variable(answer)
- Bouncy Ball(answer)
- Booleans(answer)
- Classes & Objects(answer)
- Conditionals + for Loop(answer)
- Classes & Objects(answer)
- Dist()(answer)