import java.awt.geom.*; import java.lang.Math; import java.lang.*; public class Rectangle{ Point2D.Double origin; Point2D.Double corner; public Rectangle(double x1, double y1, double x2, double y2){ origin = new Point2D.Double(x1,y1); corner = new Point2D.Double(x2,y2); } public double largeur(){ double calcX, calcY; calcX= (Math.abs(origin.getX()-corner.getX())); calcY= (Math.abs(origin.getY()-corner.getY())); return Math.min(calcX, calcY); } public double longueur(){ double calcX, calcY; calcX= (Math.abs(origin.getX()-corner.getX())); calcY= (Math.abs(origin.getY()-corner.getY())); return Math.max(calcX, calcY); } public double surface(){ return (largeur()*longueur()); } public double perimetre(){ return (2*largeur()+2*longueur()); } public String toString(){ return "("+origin.toString() +","+corner.toString()+")"; } }