帮你写了一点代码,看看吧。publicclassGenerateRectangle{publicstaticvoidmain(String[]args){Rectangle[]rects=newRectangle[10];intx,y;doublewidth,height;for(inti=0;i<10;i++){Rectangler=newRectangle();x=(int)(Math.random()*100);y=(int)(Math.random()*100);r.setCoordinate(x,y);width=(int)(Math.random()*1000);height=(int)(Math.random()*1000);r.setWidthAndHeight(width,height);rects[i]=r;System.out.println(r.toString());}}}classRectangle{privateintx;privateinty;privatedoublewidth;privatedoubleheight;/***设置坐标**@since2017-5-27*/publicvoidsetCoordinate(intx,inty){this.x=x;this.y=y;}publicvoidsetWidthAndHeight(doublewidth,doubleheight){this.width=width;this.height=height;}@OverridepublicStringtoString(){return"矩形坐标[x="+x+",y="+y+",宽度="+width+",高度="+height+"]";}}
追问你tm在逗我,根本不是一个东西
本回答被网友采纳