Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need the following code animated. It doesn\'t matter if it just bounces around

ID: 3545528 • Letter: I

Question

I need the following code animated. It doesn't matter if it just bounces around or just moves off the screen.


import java.applet.Applet;
import java.awt.*;

public class Pumpkin extends Applet
{
public void paint (Graphics page)
{

final int MID = 175;
final int TOP = 175;
Color background = new Color(0,17,102);
page.setColor (background);
setBackground (background);



page.setColor (background);


Color pumpkin = new Color(255,127,2);
page.setColor (pumpkin);
page.fillOval (MID-135,TOP-120,275,250); //head

page.setColor (Color.black);
page.drawOval (MID-120,TOP-121,240,250);
page.drawOval (MID-90,TOP-121,180,250);
page.drawOval (MID-60,TOP-121,120,250);

page.setColor (Color.yellow);
int x1Point[] = {MID-80,MID-60,MID-40}; // x1 coordinates
int y1Point[] = {TOP-30,TOP-70,TOP-30}; // y1 coordinates
page.fillPolygon (x1Point,y1Point,x1Point.length); //right eye
int x2Point[] = {MID+35,MID+55,MID+75}; // x2 coordinates
int y2Point[] = {TOP-30,TOP-70,TOP-30}; // y2 coordinates
page.fillPolygon (x2Point,y2Point,x2Point.length); // left eye


Color stem = new Color(32,87,37);
page.setColor (stem);
page.fillRect(MID-20,TOP-150, 35,50);

page.setColor(Color.yellow);
page.fillArc (MID-80,TOP-10,160,100,180,180); //smile
int x3Point[] = {MID-20,MID,MID+20}; // x3 coordinates
int y3Point[] = {TOP-20,TOP+20,TOP-20}; // y3 coordinates
page.fillPolygon (x3Point,y3Point,x3Point.length); // nose

page.setColor (pumpkin);
page.fillRect (MID-45, TOP+40, 20, 30); //tooth
page.fillRect (MID+25, TOP+40, 20, 30); //tooth
page.fillRect (MID-10, TOP+60, 20, 30); //tooth
page.fillOval (MID-70,TOP-45,20,20); //right pupil
page.fillOval (MID+45,TOP-45,20,20); //left pupil

setSize(350, 350);
}
}

Explanation / Answer

import java.applet.Applet;
import java.awt.*;

public class Pumpkin extends Applet
{
public void paint (Graphics page)
{

final int MID = 175;
final int TOP = 175;
Color background = new Color(0,17,102);
page.setColor (background);
setBackground (background);



page.setColor (background);


Color pumpkin = new Color(255,127,2);
page.setColor (pumpkin);
page.fillOval (MID-135,TOP-120,275,250); //head

page.setColor (Color.black);
page.drawOval (MID-120,TOP-121,240,250);
page.drawOval (MID-90,TOP-121,180,250);
page.drawOval (MID-60,TOP-121,120,250);

page.setColor (Color.yellow);
int x1Point[] = {MID-80,MID-60,MID-40}; // x1 coordinates
int y1Point[] = {TOP-30,TOP-70,TOP-30}; // y1 coordinates
page.fillPolygon (x1Point,y1Point,x1Point.length); //right eye
int x2Point[] = {MID+35,MID+55,MID+75}; // x2 coordinates
int y2Point[] = {TOP-30,TOP-70,TOP-30}; // y2 coordinates
page.fillPolygon (x2Point,y2Point,x2Point.length); // left eye


Color stem = new Color(32,87,37);
page.setColor (stem);
page.fillRect(MID-20,TOP-150, 35,50);

page.setColor(Color.yellow);
page.fillArc (MID-80,TOP-10,160,100,180,180); //smile
int x3Point[] = {MID-20,MID,MID+20}; // x3 coordinates
int y3Point[] = {TOP-20,TOP+20,TOP-20}; // y3 coordinates
page.fillPolygon (x3Point,y3Point,x3Point.length); // nose

page.setColor (pumpkin);
page.fillRect (MID-45, TOP+40, 20, 30); //tooth
page.fillRect (MID+25, TOP+40, 20, 30); //tooth
page.fillRect (MID-10, TOP+60, 20, 30); //tooth
page.fillOval (MID-70,TOP-45,20,20); //right pupil
page.fillOval (MID+45,TOP-45,20,20); //left pupil

setSize(350, 350);
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote