mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-10-12 00:13:56 +00:00
Added class hierarchies.
This commit is contained in:
1 parent
2029609def
commit
41b818771e
6 files changed
+78
No files matched your search
@@ -0,0 +1,33 @@
|
||||
package com.iluwatar;
|
||||
|
||||
public class Rectangle {
|
||||
|
||||
private int left;
|
||||
private int top;
|
||||
private int right;
|
||||
private int bottom;
|
||||
|
||||
public Rectangle(int left, int top, int right, int bottom) {
|
||||
this.left = left;
|
||||
this.top = top;
|
||||
this.right = right;
|
||||
this.bottom = bottom;
|
||||
}
|
||||
|
||||
public int getLeft() {
|
||||
return left;
|
||||
}
|
||||
public int getTop() {
|
||||
return top;
|
||||
}
|
||||
public int getRight() {
|
||||
return right;
|
||||
}
|
||||
public int getBottom() {
|
||||
return bottom;
|
||||
}
|
||||
|
||||
boolean intersectsWith(Rectangle r) {
|
||||
return !(r.getLeft() > getRight() || r.getRight() < getLeft() || r.getTop() > getBottom() || r.getBottom() < getTop());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user