Program: The main activities of this program are to draw shapes using different
ID: 3865417 • Letter: P
Question
Program:
The main activities of this program are to draw shapes using different kinds of Java drawing methods. Particularly, you are asked to draw a frosty snowman. Use your imagination, but be sure that Frosty has the following snowman-like properties.
Requirements:
A tripartite body (3 ovals, possibly circles)
Rectangular buttons of some non-white color on the middle oval.
Branches for arms sticking out of the middle oval.
The top oval, the head, has the following properties:
Two eyes, some sort of oval
A carrot nose, drawn as a polygon
A red licorice mouth (drawn as an arc)
A hat on the head, drawn as a polygon
Draw a scarf with writing on it
Technical requirements are:
Use two classes pattern to do the job: name the application class “TestSnowMan” and name the work class “SnowMan”. Your implementation for this assignment must use JFrame.
Draw a class diagram in the space below (your class diagram must match your code)
Answer:
Paste your complete source code here (code needs to conform to Java coding convention (be consistent and indent appropriately))
Answer:
Explanation / Answer
import java.awt.*; import java.applet.*; publicclass LineRect extends Applet { publicvoid paint(Graphics g) { g.drawLine(10,10,50,50); g.drawRect(10,60,40,30); g.setColor(Color.blue); g.fillRect(60,10,30,80); g.setColor(Color.green); g.drawRoundRect(10,100,80,50,10,10); g.setColor(Color.yellow); g.fillRoundRect(20,110,60,30,5,5); g.setColor(Color.red); g.drawLine(100,10,230,140); g.drawLine(100,140,230,10); g.drawString("Line Rectangles Demo",65,180); g.drawOval(230,10,200,150); g.setColor(Color.blue); g.fillOval(245,25,100,100); } };
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.