Code:Hi again! Now my program is working but I have problem whit Print out. How can I solve this problem. class myOverLoad{ int x1=0; int y1=0; int x2=0; int y2=0; myOverLoad buildRect(int x1, int y1, int x2, int y2){ this.x1=x1; this.y1=y1; this.x2=x2; this.y2=y2; return this; } myOverLoad buildRect(Point topleft, Point bottomRight){ x1=topleft.x; y1=topleft.y; x2=bottomRight.x; y2=bottomRight.y; return this; } myOverLoad buildRect(Point topleft, int w, int h){ x1=topleft.x; y1=topleft.y; x2=(x1+w); y2=(y1+h); return this; } } class Overload1{ public static void main (String[]args){ my.buildRect(1, 2, 3, 4); my.buildRect(new Point(1,2), new Point(3,4)); my.buildRect(new Point(1,2),10,11); System.out.println(my.buildRect(1, 2, 3, 4)); System.out.println(my.buildRect(new Point(5,6), new Point(7,8) )); System.out.println(my.buildRect(new Point(5,6), new Poin(7,8) )); } }


Reply With Quote


Bookmarks