Code:
import java.awt.Point;
class myOverLoad{
int x1=0;
int y1=0;
int x2=0;
int y2=0;
public myOverLoad buildRect(int x1, int y1, int x2, int y2){
this.x1=x1;
this.y1=y1;
this.x2=x2;
this.y2=y2;
return this;
}
public myOverLoad buildRect(Point topleft, Point bottomRight){
x1=topleft.x;
y1=topleft.y;
x2=bottomRight.x;
y2=bottomRight.y;
return this;
}
public 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){
myOverLoad my = new myOverLoad();
my.buildRect(1, 2, 3, 4);
my.buildRect(new Point(1,2), new Point(3,4));
my.buildRect(new Point(1,2),10,11);
}
}
As for coding your own Point class I cannot see how that could be of any
help at all.
Bookmarks