Solved

# how to construct a square

Posted on 2005-03-02

i have the cordinates of each corner but i dont know what to do with them. I think that i need to take all those cordinates and put them together but im not really sure how.

any help

Thanks

Ted

Square s = new Square(30,20,50,10);

System.out.println("\nSquare:");

System.out.println("The Distance From Top Left To Top Right = " + s.topLeft.getDistance(s.topRight));

System.out.println("The Distance From Top Left To Bottom Left = " + s.topLeft.getDistance(s.bottomLeft));

System.out.println("The Distance From Bottom Left To Bottom Right = " + s.bottomLeft.getDistance(s.bottomRight));

System.out.println("The Distance From Bottom Right To Top Right = " + s.bottomRight.getDistance(s.topRight));

System.out.println(s.enclose);

}

}

--------------------------------------------------------------

public class Square{

Point topLeft;

Point topRight;

Point bottomRight;

Point bottomLeft;

Point enclose;

public Square(double x1, double y1, double x2, double y2) {

topLeft = new Point(Math.min(x1,x2),Math.max(y1,y2));

bottomLeft = new Point(Math.min(x1,x2),Math.min(y1,y2));

topRight = new Point(Math.max(x1,x2),Math.max(y1,y2));

bottomRight = new Point(Math.max(x1,x2),Math.min(y1,y2));

}

public Square(Point topLeft, Point topRight, Point bottomLeft, Point bottomRight){

}

public Square enclose(){

return new Square(topLeft, topRight, bottomLeft, bottomRight);

}

}

}