Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Daniel Lawson
- 9/22/2016
- Exercise 2:
- public void flip(){
- int tempX = x;
- x = -y;
- y = -tempX;
- }
- Exercise 3:
- public int manhattanDistance(Point other){
- return (Math.abs(x-other.getX()) + Math.abs(y-other.getY()));
- }
- Exercise 4:
- public boolean isVertical(Point other){
- return(x == other.getX());
- }
- Exercise 5:
- public double slope(Point other){
- if(x == other.getX())throw new IllegalArgumentException("Your x values can't be the same!");
- return Math.round((((y2-y1)/(x2-x1)) * 10000.0) / 10000.0); //return((y-other.getY())/(x-other.getX));
- }
- Exercise 6:
- public boolean isCollinear(Point p1, Point p2){
- return(slope(p1) == slope(p1));
- }
Advertisement
Add Comment
Please, Sign In to add comment