没办法,我在学.net,java要大三学,可是同学问到头上来我也要帮忙啊.
要求如下:
首先做一个300*300的窗口,蓝色背景
窗口里画数个红色长方形和绿色椭圆,长方形0-2个(个数随机)椭圆0-3个(个数随机)
其中:
长方形的长与宽是1-10(单位cm)的随机数,如果长宽相等的画,异常,抛出,不画。那些合法的长方形,要在其下面显示周长和面积的值椭圆的高与宽也是1-15的随机数,如果产生的长与宽相等,则在图形下面打出它的周长和面积
第一个图形的初始坐标是(10,10),图形不能重叠,应成一列顺序排列,在每个图下面,一个字符串显示图形的计算公式和单位
所有的长方形和椭圆画完后,打印出一共花了多少个长方形和椭圆 还有英文版的要求:
Java Programming 2006
Course Code: ELB-2201
Coursework 11 – ‘retake’
Mini-Project
1. Create an applet that draws a random number (as specified below) of rectangles and ovals and prints a
total count for each type of shape, together with some measurements for each type of shape. The applet
should:
   Draw a window of 300 by 300 pixels with a BLUE background colour.
   Determine how many rectangles and ovals should be drawn. This should be a random integer
number:
a. between 0 and 2 for rectangles;
b. between 0 and 3 for ovals.
   All rectangles should be RED and all ovals should be GREEN.
   The size and measurements of the rectangles and ovals to be drawn should be as follows:
o Rectangles:
   The width and height should both be random integer numbers between 1 and 10.
   If the determined width and height numbers are the same, then this is not a valid
rectangle. Create the IllegalRectangleException class to signal when
an illegal rectangle has been created. Any illegal rectangles should not be drawn
or counted.
   For any valid rectangles, determine and print their area and perimeter below the
drawn shape – assume that the rectangle’s height and width are given in
centimetres.
o Ovals:
   The width and height should both be random integer numbers between 1 and 15.
   If the determined width and height numbers are the same (i.e., the oval is a
circle), then determine and print their area and perimeter – assume that the
oval’s height and width are given in centimetres.
   The initial coordinates for the first shape to be drawn are (x, y) = (10, 10). You should make sure
that your shapes do not overlap and appear in sequence (as a column of shapes). Below each
shape drawn, a string should appear indicating their measurements (and the units).
   After all the rectangles and ovals have been drawn, print a string indicating how many rectangles
and ovals have been drawn.
   You should provide:
o A class that defines a general GeometricShape (since we may want to extend this
program in the future and add other different shapes). Name your program
GeometricShape.java.
o Classes that define a Rectangle and an Oval – they should be subclasses of
GeometricShape and include the implementation of two methods, named
calculateArea and calculatePerimeter. Name your programs
Rectangle.java and Oval.java.
o A class containing the exception for signalling that an attempt was made to create an
illegal rectangle. Name your program IllegalRectangleException.java.
o A class with the applet. Name your program PrintAndMeasureShapes.java.
o The HTML file that loads the applet. Name your file MyShapesApplet.html.
[20 MARKS]
Don’t forget your Javadocs and internal comments!大大们帮忙啊.