//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 (凸多边形)