Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Rectangle {
- public double x1, y1, x2, y2, a, b;
- public Rectangle(double x1, double y1, double x2, double y2, boolean bothCoordinates){
- this.x1= x1;
- this.y1= y1;
- if(bothCoordinates == true){
- this.x2= x2;
- this.y2= y2;
- this.setSides();
- }else{
- this.a= x2;
- this.b= y2;
- this.setPoint();
- }
- }
- public double getField(){
- return a*b;
- }
- public double getCircuit(){
- return 2*a+2*b;
- }
- public void setPoint(){
- this.x2= this.x1+b;
- this.y2= this.y1+a;
- }
- public void setSides(){
- this.a= this.y2-this.y1;
- this.b= this.x2-this.x1;
- }
- public double getdLength(){
- return Math.sqrt(Math.pow(x1-x2,2)+Math.pow(y1-y2,2));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement