急求JAVA高人帮忙

请大家帮帮忙,我有急用,我愿意拿出我所有的分,谢谢大家了
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 500 by 500 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 10
and 25.
􀂃 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
values (rounded to 2 decimal places) 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 10 and
50.
􀂃 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 (rounded to 2 decimal places).
􀀹 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 must 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.
首先做一个500*500的窗口,蓝色背景
窗口里画数个红色长方形和绿色椭圆,长方形0-2个(个数随机)椭圆0-3个(个数随机)
其中:
长方形的长与宽是10-25(单位cm)的随机数,如果长宽相等的画,异常,抛出,不画。那些合法的长方形,要在其下面显示周长和面积的值

椭圆的高与宽也是10-50的随机数,如果产生的长与宽相等,则在图形下面打出它的周长和面积
第一个图形的初始坐标是(10,10),图形不能重叠,应成一列顺序排列,在每个图下面,一个字符串显示图形的计算公式和单位
所有的长方形和椭圆画完后,打印出一共花了多少个长方形和椭圆
麻烦帮我写一下这个程序啊

写一个applet。
要求:
1. applet的背景大小是500*500,蓝色。
2. 用Math.Random来获得两个随机数,一个在0到2之间,一个在0到3之间。0到2之间的数决定了你等一下要画的矩形数量,0-3则是椭圆的数量。
3. 矩形要用红色画,椭圆则是绿色。矩形的长宽也是随机生成,大小要在10到25之间,并且不能相同,一旦相同就抛出IllegalRectangleException (这个异常要自己写)。画出了矩形之后要在矩形的下方写出矩形的长宽、面积和周长,精确到小数点后两位(假设单位是厘米)。椭圆长宽也一样要随机生成,大小则是在10到50之间,可以相同,一样在图形的下方写出长宽、面积和周长,精确到小数点后两位。
4. 图形按照列的形式排列画出(也就是说一列一列画出,不是一行一行画出),并且确保不会发生重叠的现象。画完再统计分别写出画了多少个矩形和多少个椭圆。

具体的类文件定义限制:
1. 写一个几何图形GeometricShape类,这是你下面要写的矩形类Rectangle 和椭圆类Oval的父类。
2. 分别写出矩形类Rectangle 和椭圆类Oval,实现两个方法,即计算面积的calculateArea() 和 计算周长的calculatePerimeter()。(个人建议是将这两个方法和面积、周长变量定义在父类GeometricShape,然后在子类里面覆盖重写,因为所有的几何图形都可以有面积和周长的嘛~~,然后再于矩形类Rectangle 和椭圆类Oval之中定义两个个变量,即长、宽,便于等下用Graphics的fillOval(int x, int y, int width, int height)来画图形)
3. IllegalRectangleException异常的定义,直接继承于Exception,覆盖无参数的那个构造函数,在里面调用super("非法的矩形长宽定义");就行了。
4. 最后就是写applet啦,名字叫PrintAndMeasureShapes。要求就按上面的做。最后写一个MyShapesApplet.html来显示调用这个applet。

代码私下给~~
温馨提示:答案为网友推荐,仅供参考
第1个回答  2009-09-23
创建一个小程序,绘制一个随机数(如下述)的矩形和椭圆形,并打印1
的总数为各种形状类型,连同各种形状类型的某些测量。小程序
应:
􀀹绘制500像素500窗口,蓝色背景颜色。
􀀹确定有多少长方形和椭圆应当制定。这应该是一个随机整数
编号:
字母a. 0和2之间的矩形;
湾介于0和3椭圆形。
􀀹所有矩形应为红色,所有椭圆应该是绿色。
􀀹的规模和矩形和椭圆测量得出应该如下:
Ø矩形:
􀂃的宽度和高度都应该定为10至随机整数
和25。
如果􀂃的宽度和高度确定的数字是相同的,那么这不是一个
有效的矩形。创建IllegalRectangleException类信号
当一个非法的矩形已创建。任何非法矩形不应该
绘制或计算。
对于任何有效的矩形􀂃,确定和打印的面积和周长
值(四舍五入至两个小数位低于绘制的形状- )假设
矩形的高度和宽度都给予厘米。
Ø椭圆:
􀂃的宽度和高度都应该在10至随机整数
50。
如果确定的宽度和高度号码是相同的(即􀂃,椭圆形,是一
圈),然后确定并打印其面积和周长-假设
椭圆形的高度和宽度都给予厘米(四舍五入到2位小数)。
􀀹最初的第一个形状要绘制坐标是(的x,y)=(10,10)。你应该
确保您的形状不重叠,并出现在序列(如形状列)。以下各
形状绘制,应该会出现一个字符串,表明他们的测量结果(和单位)。
􀀹毕竟矩形和椭圆已经制定,打印一个字符串显示有多少
矩形和椭圆已经制定。
􀀹您必须提供:
o一个类定义了一个一般GeometricShape(因为我们可能要延长这一
计划在将来添加其他不同的形状)。您的程序名称
GeometricShape.java。
O类定义一个Rectangle和一个椭圆形-他们应该子类
GeometricShape和包括两种方法命名,执行
calculateArea和calculatePerimeter。您的程序名称
Rectangle.java和Oval.java。
Ø A级载有信号,一个试图创造一个例外
非法矩形。名称程序IllegalRectangleException.java。
Ø与applet的A级。名称程序PrintAndMeasureShapes.java。
地址为HTML文件,加载的小程序。为您的文件MyShapesApplet.html
第2个回答  2009-09-23
比较麻烦

¥200可以考虑一下

呵呵
第3个回答  2009-09-23
这个确实该RMB了

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网