//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 (凸多边形)
解决方案 »
- 集合ArrayList的add怎么编译不过?
- 如何比较两组数据---在线等
- 一个图形界面的显示问题!帮忙看看
- java中有关载入包的疑惑。
- java颜色转换
- 一个简易计算器的问题,求大仙们帮帮忙
- 为什么相同的代码在win下运行正常,而在linux下就出错呢?
- 特别奇怪的的问题 大家都来发表一下意见
- 字符串处理难题?
- 如何两个form 参数传递
- 为什么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();