これはあなたが意味するものですか?
java GeoTest
[{0.0,0.0}, {0.0,10.0}, {10.0,10.0}, {10.0,0.0}]
コード:
import java.util.Arrays;
public class GeoTest{
public static void main(String[] args){
System.out.println(Arrays.toString(new Square(new Point(0,0), new Point(10,10)).getCourners()));
}
}
class Point{
private double x;
private double y;
public Point(double x, double y) {
this.x = x;
this.y = y;
}
public String toString(){
return new String("{"+x+","+y+"}");
}
public double getX(){
return x;
}
public double getY(){
return y;
}
}
class Square {
private Point lowerLeft;
private Point upperRight;
/**
* Assuming x & y axis as follows:
* Lower left corner (x,y):0,0 -> upper right corner (x,y): n,n where n > 0
*/
public Square(Point lowerLeft, Point upperRight){
this.lowerLeft = lowerLeft;
this.upperRight = upperRight;
}
public Point[] getCourners(){
return new Point[]{lowerLeft, new Point(lowerLeft.getX(),upperRight.getY()),upperRight, new Point(upperRight.getX(), lowerLeft.getY())};
}
}