Created
June 21, 2017 10:38
-
-
Save eyalcohen4/3974494cc5516010daf55d2eff104d6e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public double calcPerimeter() { | |
double peri = 0; | |
if (head.getNext() == null) { | |
return peri; | |
} else if (head.getNext().getNext() == null) { | |
return head.getPoint().distance(head.getNext().getPoint()); | |
} | |
PointNode iterable = head; | |
while (iterable.getNext().getNext() != null) { | |
if (iterable.getNext() == null) { | |
peri += iterable.getPoint().distance(head.getPoint()); | |
} else { | |
peri += iterable.getPoint().distance(iterable.getNext().getPoint()); | |
iterable = iterable.getNext(); | |
} | |
} | |
return peri; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment