I am having trouble with this problem:

*You might notice the “contains” method that comes with the java.awt.Rectangle class we’ve been using returns false if the point is on the lower or right edge of the Rectangle (for example the program will refuse to deliver to a customer at (1,8) or (4,2) even though these points are in store 1’s range. Instead of using the Rectangle’s “contains” method, write your own method that takes a Rectangle, a x value, and a y value, and returns true (and false otherwise) if the point (x,y) is located inside or on ANY edge of the Rectangle parameter. Use your new method in the program wherever you used the Rectangle’s “contains” method before.*

So basically I have to write a method that will return true or false when I input a rectangle, and a point.

I know that Rectangle store will have a starting point (upper left corner), and a certain width and height. So the input of x and y will have to fall inside of these constraints of this rectangle.

In general, if (a, b ) represents the upper left corner of the rectangle, respectively, and (c,d) represents the height and width of the rectangle, respectively, point (x,y) lies in (or on the border) of the rectangle if and only if:

a <= x <= a + c

AND

b <= y <= b + d

(Please correct me on the above logic if I am indeed incorrect. That is just my approximation.)

I am having trouble coding this. I'm not sure how to extract the (a,b ) [upper left corner coordinates] and (c, d) [height and width] from the input rectangle. Would this even be the right approach?

Any assistance would be much appreciated!

This post has been edited by **winterwind**: 13 October 2009 - 02:33 PM