通过java画一个大风车.doc*/
今天的作业我做的是画一个风车 :
运行结果:
Ud 大风车
1首先:写个Point类:(作用作为风车的中点)
package ;
/**
***@author黄燕斌
***@version
***@since 2013 - 05-28
*/
public class Point {
private
double
x;
private
double
y;
/**
*构造器
*/
public
Poi nt(){
/** *构造器 * ***@paramx * ***@paramy */
public
Point( double x, double y){
this
.x = x;
this
.y = y;
/**
***@return X
*/
public double getX() { return x;
}
/**
* ***@paramx X
*/
*/
public void setX( int x) { this . x = x;
}
* ***@return Y
*/
public double getY() { return y;
}
***@paramy Y
public void setY( int y) {
this . y = y;
}
}
Windmill类
package ;
import ;
import ;
风车
***@author 黄
***@versio n
***@since 2013 - 05-28
*/
public class Windmill {
private Poi nt center
private int radius ;
private Color color
public Win dmill(){
构造器
***@paramce nter
***@paramradius
***@paramcolor
*/
radius,Color
public Win dmill(Poi nt cen ter, int
color){
this
.radius
=radius;
this
.center
=cen ter;
this
.color =
=color;
}
public Color getColor() { return color ;
}
public void setColor(Color color) {
this . color = color;
public Point getCe nter() {
return center ;
}
public void setCenter(Point center) { this . center = center;
}
public int getRadius() {
return radius ;
}
/**
public void setRadius( int radius) { this . radius = radius;
画风车
public
*/
***@paramg
void draw(Graphics g){ /**
通过计算出风车10点的位置
*/
int arrayX[] = new int [10];
int arrayY[] = new int [10];
Pointpl = newPoint( center .getX(), center .getY()+
radius );
Point p3 = new
Point( center .getX()+Math. cos(18*Math. PI/180)* radius , c enter .getY()+Math. sin (18*Math. PI /180)* radius );
Point p5 = new
Point( center .getX()+Math. cos (54*Math. PI /180)* radius , c enter .getY()-Math. sin (54*Math. PI /180)* radius );
Point p7 = new
Point( center .getX()-Math. cos (54*Math. PI /180)* radius , c enter
通过java画一个大风车 来自淘豆网m.daumloan.com转载请标明出处.