https://www.tutorialspoint.com/javafx/index.htm e Make sure you can compile and
ID: 3748220 • Letter: H
Question
https://www.tutorialspoint.com/javafx/index.htm e Make sure you can compile and run the Snowman,java code on your own machine before you proceed. Note: Snowman.java is working code for a stand-alone application but CANNOT be run on hills. You must have code on your own machine. Use this file as a starting point for this assignment. Here are the modifications you need to make: a) Add a third red button to the upper torso b) Give the snowman a mouth instead of of the line he has now (you will need to use the JavaFX Ellipse class to create the smile) c) Move the sun to the upper-right corner of the picture d) Display your name in the upper-left corner of the picture e) Shift the snowman 20 pixels to the right 2) Compile your updated application: javac Snowman.javaExplanation / Answer
import javax.swing.JApplet;
import java.awt.*;
public class Snowman extends JApplet
{
//-----------------------------------------------------------------
// Draws a snowman.
//-----------------------------------------------------------------
public void paint (Graphics page)
{
final int MID = 150;
final int TOP = 50;
setBackground (Color.cyan);
page.setColor (Color.blue);
page.fillRect (0, 175, 300, 50); // ground
page.setColor (Color.yellow);
page.fillOval (-40, -40, 80, 80); // sun
page.setColor (Color.white);
page.fillOval (MID-20, TOP, 40, 40); // head
page.fillOval (MID-35, TOP+35, 70, 50); // upper torso
page.fillOval (MID-50, TOP+80, 100, 60); // lower torso
page.setColor (Color.black);
page.fillOval (MID-10, TOP+10, 5, 5); // left eye
page.fillOval (MID+5, TOP+10, 5, 5); // right eye
page.drawArc (MID-10, TOP+20, 20, 10, 190, 160); // smile
page.drawLine (MID-25, TOP+60, MID-50, TOP+40); // left arm
page.drawLine (MID+25, TOP+60, MID+55, TOP+60); // right arm
page.drawLine (MID-20, TOP+5, MID+20, TOP+5); // brim of hat
page.fillRect (MID-15, TOP-20, 30, 25); // top of hat
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.