Quick Index
Problem Statement


Enhance your Point class (from previous work) with logical methods.

Notes:


Getting Started


Use your most recent Point.java and add the construtor methods shown below.
Method Name
Description
Add Constructor
Add Constructor
Add a two-arg constructor. The params/args should be for x and y.
getX
The method getX should return the value of ivar y (it may be coded already from previous challenge).
getY
Similar to getX except named getY returning value of ivar y.


Logical Methods


Add the following methods to class Point.
Method Name
Description
isBalanced
Return true/false to indicate if point is balanced (we define balanced for this problem that as when x is equal to y)
isAtOrigin
Return true if both x and y are zero
reset
Receives two params both booleans with names "resetX" and "resetY". If "resetX" is true, set "x" to zero. Likewise for "resetY" with "y". Return true if both x and y are zero
print
Same method header as the Rectangle "print" method. If option is false, just print x and y. If true, use your imagination for what to print about the point. Include programming logic.
isRightOf
Receives param otherPoint. Return true/false to indicate if this point is right of otherPoint.
isRightAndAbove
Receives param otherPoint. Return true/false to indicate if this point is right and above otherPoint.
isInside
return true if point is inside the rectangle defined by the params. If the point is on the edge of the rectangle, call it "inside". The params are all type "int" and are named "leftX", "topY", "width", "height". They define the rectangle. See sketches below for more information.


isInside Sketches


A few sketches to help understand isInside


Given Properties
Showing the four given properties of the rectangle/frame:

  • leftX
  • topY
  • width
  • height
With Values
Showing some example values:

  • topY = 150
  • height = 50
  • leftX = 200
  • width = 100
Calculated Values
We can calculate the rightX edge of the rectangle/frame and the bottomY edge of the rectangle/frame, as shown.
Relative to Points
Showing one point inside and one point outside the rectangle/frame.