Resolves checkstyle errors for facade factory-kit spatial-partition state step-builder (#1077)

* Reduces checkstyle errors in facade

* Reduces checkstyle errors in factory-kit

* Reduces checkstyle errors in spatial-partition

* Reduces checkstyle errors in state

* Reduces checkstyle errors in step-builder
This commit is contained in:
Anurag Agarwal
2019-11-12 01:51:12 +05:30
committed by Ilkka Seppälä
parent 2628cc0dfc
commit c954a436ad
29 changed files with 195 additions and 197 deletions
@@ -24,35 +24,37 @@
package com.iluwatar.spatialpartition;
/**
* The Rect class helps in defining the boundary of the quadtree and is also used to
* define the range within which objects need to be found in our example.
* The Rect class helps in defining the boundary of the quadtree and is also used to define the
* range within which objects need to be found in our example.
*/
public class Rect {
double x;
double y;
double coordinateX;
double coordinateY;
double width;
double height;
//(x,y) - centre of rectangle
Rect(double x, double y, double width, double height) {
this.x = x;
this.y = y;
this.coordinateX = x;
this.coordinateY = y;
this.width = width;
this.height = height;
}
boolean contains(Point p) {
return p.x >= this.x - this.width / 2 && p.x <= this.x + this.width / 2
&& p.y >= this.y - this.height / 2 && p.y <= this.y + this.height / 2;
return p.coordinateX >= this.coordinateX - this.width / 2
&& p.coordinateX <= this.coordinateX + this.width / 2
&& p.coordinateY >= this.coordinateY - this.height / 2
&& p.coordinateY <= this.coordinateY + this.height / 2;
}
boolean intersects(Rect other) {
return !(this.x + this.width / 2 <= other.x - other.width / 2
|| this.x - this.width / 2 >= other.x + other.width / 2
|| this.y + this.height / 2 <= other.y - other.height / 2
|| this.y - this.height / 2 >= other.y + other.height / 2);
return !(this.coordinateX + this.width / 2 <= other.coordinateX - other.width / 2
|| this.coordinateX - this.width / 2 >= other.coordinateX + other.width / 2
|| this.coordinateY + this.height / 2 <= other.coordinateY - other.height / 2
|| this.coordinateY - this.height / 2 >= other.coordinateY + other.height / 2);
}
}