Question: Java in processing3 Fill in the blanks and provide the missing methods so the program below shows the light as a yellow circle when on

Java in processing3

Fill in the blanks and provide the missing methods so the program below shows the light as a yellow circle when on and black when off. Pressing the 'n' key will turn the light oN and pressing the 'f' key will turn the light oFf. Clicking on the light will make it come on if it was off and go off if it was on. Clicking elsewhere does nothing.

Light light;

void setup() {

size(400, 400);

light = new Light(width/2, height/2, 20);

noStroke();

}

void draw() {

light.draw();

}

void mousePressed() {

if (light.mouseOn())

light.toggle();

}

void keyPressed() {

if (key == 'n') light.turnOn();

else if (key == 'f') light.turnOff();

}

class Light {

int clr = color(255, 255, 0);

int x, y, diam;

boolean on = false;

Light(int xPos, int yPos, int sz) { ______________________________

______________________________

______________________________

}

void draw() {

if (on) fill(clr);

else fill(0);

ellipse(x, y, diam, diam);

}

boolean mouseOn() {

return _______________________________________ <= ___________________________;

}

void toggle() { on = !on; }

// add missing methods below here

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!