SHARE
TWEET

Untitled

a guest Oct 23rd, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Rectangle {
  2.     public double x1, y1, x2, y2, a, b;
  3.     public Rectangle(double x1, double y1, double x2, double y2, boolean bothCoordinates){
  4.         this.x1= x1;
  5.         this.y1= y1;
  6.         if(bothCoordinates == true){
  7.             this.x2= x2;
  8.             this.y2= y2;
  9.             this.setSides();
  10.         }else{
  11.             this.a= x2;
  12.             this.b= y2;
  13.             this.setPoint();
  14.         }
  15.     }
  16.     public double getField(){
  17.         return a*b;
  18.     }
  19.     public double getCircuit(){
  20.         return 2*a+2*b;
  21.     }
  22.     public void setPoint(){
  23.         this.x2= this.x1+b;
  24.         this.y2= this.y1+a;
  25.     }
  26.     public void setSides(){
  27.         this.a= this.y2-this.y1;
  28.         this.b= this.x2-this.x1;
  29.     }
  30.     public double getdLength(){
  31.         return Math.sqrt(Math.pow(x1-x2,2)+Math.pow(y1-y2,2));
  32.     }
  33. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top