![]() |
Assignment 8TaskWrite a user interface class that lets a non-programmer use wheels to draw shapes on a frame. Details:WheelsUse the most recent version of wheels: intwheels.jar DrawingFrame.java
A
Then write a public boolean drawShape()
This method will ask the user to enter all the details of the shape they want to draw: shape, x-coordinate, y-coordinate, width, height, and color. They will enter this information, separated by spaces, in a single line at the console. This method will then check that all the entered details are valid. If not, it will print out exactly what is incorrect (and return Here are the steps involved in writing this method:
Now add a ExamplesHere is an example of the program running:
This program draws shapes for you on a graphical frame.
You can draw rectangles or ellipses. The frame is 700 by 500.
Possible colors include black, red, blue, green, and custom.
Enter a shape to draw.
Format: shape xPos yPos width height color
:circle -5 1000 5 -5 purple
Error: "circle" is an unrecognized shape.
Error: x coordinate is not within the bounds of the drawing frame (Max width: 700)
Error: y coordinate is not within the bounds of the drawing frame (Max height: 500).
Error: height must be greater than 0.
Error: "purple" is an unrecognized color choice.
The first three lines were printed in
This program draws shapes for you on a graphical frame. You can draw rectangles or ellipses. The frame is 700 by 500. Possible colors include black, red, blue, green, and custom. Enter a shape to draw. Format: shape xPos yPos width height color :RectanglE 0 0 100 100 custom Enter the R G B color values (0-255), separated by spaces : 100 0 100 Shape drawn. This demonstrates how the custom color part should work. This draws a purple square (rectangle of 100 x 100) in the upper left corner of the frame.
Enter a shape to draw. Format: shape xPos yPos width height color :ELLIPSE 100 100 20 5 custom Enter the R G B color values (0-255), separated by spaces : 0 300 -2 Error: Color value out of range (0-255).
Enter a shape to draw.
Format: shape xPos yPos width height color
:ellipse 10 10 10 -10 custom
Error: height must be greater than 0.
What to SubmitAttach your DrawingFrame.java file to an email. FAQ
GradingOut of 10 points:
|
~ztomasze Index :
TA Details: ICS111:
Assignment 8 http://www2.hawaii.edu/~ztomasze |
Last Edited: 01 Nov 2007 ©2007 by Z. Tomaszewski. |