diff options
| author | E7-87-83 <fungcheokyin@gmail.com> | 2021-04-25 23:40:26 +0800 |
|---|---|---|
| committer | E7-87-83 <fungcheokyin@gmail.com> | 2021-04-25 23:40:26 +0800 |
| commit | 201c70e6d8d5374f4cecbc5712eec671266b3702 (patch) | |
| tree | 849abc78113a6e89ad8094ad8dc10c1ee70994f2 /challenge-109/cheok-yin-fung/java/Box.java | |
| parent | c4020a60c8b87c299cb4814fb328a475adf930c9 (diff) | |
| download | perlweeklychallenge-club-201c70e6d8d5374f4cecbc5712eec671266b3702.tar.gz perlweeklychallenge-club-201c70e6d8d5374f4cecbc5712eec671266b3702.tar.bz2 perlweeklychallenge-club-201c70e6d8d5374f4cecbc5712eec671266b3702.zip | |
2 Perl scripts ; Java application for Task 2
Diffstat (limited to 'challenge-109/cheok-yin-fung/java/Box.java')
| -rw-r--r-- | challenge-109/cheok-yin-fung/java/Box.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/challenge-109/cheok-yin-fung/java/Box.java b/challenge-109/cheok-yin-fung/java/Box.java new file mode 100644 index 0000000000..4f3b0cdcc6 --- /dev/null +++ b/challenge-109/cheok-yin-fung/java/Box.java @@ -0,0 +1,34 @@ +// The Weekly Challenge - 109 +// Task 2 Four Squares(Rectangles) Puzzle +// Supporting codes + +class Box +{ + private Point tl, br; + + Box(int x1, int y1, int x2, int y2) { + tl = new Point(x1, y1); + br = new Point(x2, y2); + } + + Box(Point p1, Point p2) { + this(p1.x(), p1.y(), p2.x(), p2.y()); + } + + Point topLeft() { + return tl; + } + + int height() { + return br.x()-tl.x(); + } + + int width() { + return br.y()-tl.y(); + } + + boolean isEnclosed(Point p) { + return p.x() > tl.x() && p.x() < br.x() && + p.y() > tl.y() && p.y() < br.y(); + } +} |
