Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //class header for class Point
- //instance variables - an int for x and an int for y
- //default constructor to set x and y to 0
- //specified constructor to initialize specific values for x and y
- //accessors/getters for x and y
- //mutators/setters for x and y
- //toString - returns a String of the format (x, y)
- /*Add the following method to the Point class:
- public int quadrant()
- Returns which quadrant of the x/y plane this Point object falls in. Quadrant 1 contains all points whose x and y values are both positive. Quadrant 2 contains all points with negative x but positive y. Quadrant 3 contains all points with negative x and y values. Quadrant 4 contains all points with positive x but negative y. If the point lies directly on the x and/or y axis, return 0.
- */
- /*Add the following method to the Point class:
- public void flip()
- Negates and swaps the x/y coordinates of the Point object. For example, if the object initially represents the point (5, -3), after a call to flip, the object should represent (3, -5). If the object initially represents the point (4, 17), after a call to flip, the object should represent (-17, -4).
- */
- /*Add the following method to your Point class:
- public boolean isVertical(Point other)
- Returns true if the given Point lines up vertically with this Point; that is, if their x coordinates are the same.
- */
- /*Add the following method to the Point class:
- public double slope(Point other)
- Returns the slope of the line drawn between this Point and the given other Point. Use the formula (y2 - y1) / (x2 - x1) to determine the slope between two points (x1, y1) and (x2, y2). Note that this formula fails for points with identical x-coordinates
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement