//last (20,20) pair is not needed.int x[]={20,80,150,130,60,123};
int y[]={20,180,130,70,10,90};the line between the first and the last point will be drawn by drawPloygon().java.util.Random.nextInt(int n) can generate random integer
//
...
Random rd=new Random();
for(int i=0;i<pathNum;i++){
x[i]=offset.x+rd.nextInt(maxX);
y[i]=offset.y+rd.nextInt(maxY);
}
return new Polygon(x,y,pathNum);//
the hardest thing you may deal with is how to generate a ConvexPolygon (凸多边形)
int y[]={20,180,130,70,10,90};the line between the first and the last point will be drawn by drawPloygon().java.util.Random.nextInt(int n) can generate random integer
//
...
Random rd=new Random();
for(int i=0;i<pathNum;i++){
x[i]=offset.x+rd.nextInt(maxX);
y[i]=offset.y+rd.nextInt(maxY);
}
return new Polygon(x,y,pathNum);//
the hardest thing you may deal with is how to generate a ConvexPolygon (凸多边形)
解决方案 »
- 打字测速程序遇到的一个颜色显示问题求教!
- 怎么将存储在文本文档中的像素值转换成RGB图
- 一条SQL语句 引发的两个问题 请大家帮忙解决 佛祖会保佑帮我的人滴!(解决后马上送分)
- Class.forName执行问题
- 寻找RSA for java算法的实现。兄弟们请出把力!
- 关于反射,如果为数组类型,如何能够得到是哪种数组?
- jb8装好了,用第二种方法也注册"成功"了,可当再次点击jb启动的图标怎么又让我注册了啊?请问这改怎么办?谢谢
- <<Enterprise JAVA BEANS>>不适合初学者
- java的信号量(Semaphore)和线程池(ExecutorService )的区别
- 求助贴,关于方法重载
- 为什么abort.setEnable(false); 是错误的,编译不过去??
- 救命呀:java.lang.SecurityException: access denied (javax.management.MBeanTrustPermission register)
for(int i=0;i<pathNum;i++){
x[i]=offset.x+rd.nextInt(maxX);
y[i]=offset.y+rd.nextInt(maxY);
}
return new Polygon(x,y,pathNum);就是楼上说的
Random rd=new Random();
rd.nextInt();
rd.nextFloat();