title: checking if a point is inside a specified Rectangle
body: <p>ok, so i'm doing an assignment for a Java class and one part of the assignment is to find out if a point is within the dimensions of a rectangle. so I created this code:</p>
  
  <pre><code>public boolean contains(Point p) {
      return (this.getLocation().getX() &lt; p.getX() &amp;&amp; this.getLocation().getY() &lt; p.getY() &amp;&amp;
              this.getLocation().getX() + this.getWidth() &gt; p.getX()  &amp;&amp;
              this.getLocation().getY() + this.getHeight() &gt; p.getY());
  }
  </code></pre>
  
  <p>I created a <code>Point</code> class as well, which is why I asked for a <code>Point p</code> parameter. To test this <code>boolean</code> I created a simple <code>if</code> statement in my Main class: </p>
  
  <pre><code>//check if one rectangle's point is inside another
  if (rectangle.contains(rectangle2.getLocation()))
      System.out.println("the point is in the rectangle");
  </code></pre>
  
  <p>The location of the point is (6,7). The point, width, and height of rectangle 1 is (4,5), 9, and 3, respectively. I know for a fact that this point is inside the first rectangle, but the <code>println</code> statement is not showing, meaning there must be a problem with the <code>boolean</code> i created but I don't see an error, maybe my head is cloudy but can someone point out to me what's wrong here?</p>
  
  <p>P.S. this is all Console work, i'm not dealing with some GUI or graphics programming.</p>