intersects1(other) { /* Method in "Frame" class Return true if this (rectangular) frame intersects "other" (also a Frame) Both are simple rectangular frames that have (point object) corners "lt", "rt", "rb" and "lb" (i.e. left-top, right-top, right-bottom, and left-bottom). We define an intersection if any corner of "other" is in "this" frame object. If other corner is "on" any of our edges, we'll call that inside (yes an intersection) Assume frame y-axis is downward (common in computer graphics) */ //Algorithm -- no helper (buddy) methods let lt = new Point(other.getLeft(), other.getTop()), rt = new Point(other.getRight(), other.getTop()), rb = new Point(other.getRight(), other.getBottom()), lb = new Point(other.getLeft(), other.getBottom()); return ((lt.getX() >= this.getLeft() && (lt.getX() <= this.getRight())) && (lt.getY() >= this.getTop() && (lt.getY() <= this.getBottom()))) || ((rt.getX() >= this.getLeft() && (rt.getX() <= this.getRight())) && (rt.getY() >= this.getTop() && (rt.getY() <= this.getBottom()))) || ((rb.getX() >= this.getLeft() && (rb.getX() <= this.getRight())) && (rb.getY() >= this.getTop() && (rb.getY() <= this.getBottom()))) || ((lb.getX() >= this.getLeft() && (lb.getX() <= this.getRight())) && (lb.getY() >= this.getTop() && (lb.getY() <= this.getBottom()))) }
intersects2(other) { //Method in "Frame" class let lt = other.getLT(), rt = other.getRT(), rb = other.getRB(), lb = other.getLB(); return this.contains(lt) || this.contains(rt) || this.contains(rb) || this.contains(lb); }
first() { //We would also validation here let array = this.getArray(); let elem = array[0]; return elem; }
first() { //We would also validation here return this.get(0); }
first() { //We would also validation here return this.get(0); }