Code Review

Warm-up Questions

  1. What is parameterized design?
  2. What is conditional design?
  3. What are datatypes? Name 3 examples, and explain how you would declare them in JavaScript (p5) versus Java (Processing)
  4. What do each of these operators do? &&, ||, +=, ++, %
  5. What is the difference between using a single = and == ?
  6. What are three ways to write "subtract 1 from x" ?
  7. Draw a sketch of the expected output on screen for the following code.
  8. for (let i = 0; i < 5; i++){
    rect(i * 30, height/2, 30, 30);
    }
  9. Why are functions used in coding?
  10. What is the difference between a class and an object?
  11. Describe the role of the constructor method.
  12. When would you need to use a boolean variable
  13. Review the following code. What is the value of b after running this code?
  14. boolean b = false;
    b = !b;
  15. What will be printed out?
  16. boolean iLoveProgramming = true;
    print("It is “+ !(!(iLoveProgramming))) + " that I love programming!");
  17. What does the following code print out?
  18. let counter = 1;
    let num = 10;
    while (counter < num)
    {
    print(counter);
    counter++;
    }
  19. Describe in English words (pseudocode) what this program does.
  20. 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

  1. Removing Objects from an Array(answer)
  2. Local vs. Global Variable(answer)
  3. Bouncy Ball(answer)
  4. Booleans(answer)
  5. Classes & Objects(answer)
  6. Conditionals + for Loop(answer)
  7. Classes & Objects(answer)
  8. Dist()(answer)