Question: help with java Implement a Picture.java applet which displays a house a tree , three flowers (not all identical), and sky with crescent moon, five
help with java
Implement a Picture.java applet which displays a house a tree, three flowers (not all identical), and sky with crescent moon, five or more stars, a comet.and a pacman (see pic below). The stars must include 5-pointed, 6-pointed and 7-pointed varieties. The comet should be a white disk with lines emanating from it. Also, include a caption with some text. You may use any of the methods of the Graphics class. Use fillPolygon (or drawPolygon) to make the stars. Use fillOval to draw the moon (partially cover a white disk with a sky-colored disk to get a crescent).
Here's what your pacman should look like:
For nice symmetrical stars (optional) you can use sine and cosine to determine location of the points.
xs[i]= xOffset + radius * cos(i*2*Math.PI)umPoints);
and something similar for ys[i]..
Upload Picture.java and a screenshot of the running applet. (Your screenshot should just include the appletviewer window itself, not your whole desktop.) The screenshot should be saved as a gif or jpeg or .png. Suggested dimensions: 800 pixels wide x 600 pixels high.
Here's documentation for the Graphics class methods.
| void | draw3DRect(int x, int y, int width, int height, boolean raised) Draws a 3-D highlighted outline of the specified rectangle. |
| abstract void | drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) Draws the outline of a circular or elliptical arc covering the specified rectangle. |
| void | drawBytes(byte[] data, int offset, int length, int x, int y) Draws the text given by the specified byte array, using this graphics context's current font and color. |
| void | drawChars(char[] data, int offset, int length, int x, int y) Draws the text given by the specified character array, using this graphics context's current font and color. |
| abstract void | drawLine(int x1, int y1, int x2, int y2) Draws a line, using the current color, between the points (x1, y1) and (x2, y2) in this graphics context's coordinate system. |
| abstract void | drawOval(int x, int y, int width, int height) Draws the outline of an oval. |
| abstract void | drawPolygon(int[] xPoints, int[] yPoints, int nPoints) Draws a closed polygon defined by arrays of x and y coordinates. |
| void | drawPolygon(Polygon p) Draws the outline of a polygon defined by the specified Polygon object. |
| abstract void | drawPolyline(int[] xPoints, int[] yPoints, int nPoints) Draws a sequence of connected lines defined by arrays of x and y coordinates. |
| void | drawRect(int x, int y, int width, int height) Draws the outline of the specified rectangle. |
| abstract void | drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) Draws an outlined round-cornered rectangle using this graphics context's current color. |
| abstract void | drawString(AttributedCharacterIterator iterator, int x, int y) Draws the text given by the specified iterator, using this graphics context's current color. |
| abstract void | drawString(String str, int x, int y) Draws the text given by the specified string, using this graphics context's current font and color. |
| void | fill3DRect(int x, int y, int width, int height, boolean raised) Paints a 3-D highlighted rectangle filled with the current color. |
| abstract void | fillArc(int x, int y, int width, int height, int startAngle, int arcAngle) Fills a circular or elliptical arc covering the specified rectangle. |
| abstract void | fillOval(int x, int y, int width, int height) Fills an oval bounded by the specified rectangle with the current color. |
| abstract void | fillPolygon(int[] xPoints, int[] yPoints, int nPoints) Fills a closed polygon defined by arrays of x and y coordinates. |
| void | fillPolygon(Polygon p) Fills the polygon defined by the specified Polygon object with the graphics context's current color. |
| abstract void | fillRect(int x, int y, int width, int height) Fills the specified rectangle. |
| abstract void | fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) Fills the specified rounded corner rectangle with the current color. |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
