Click here to Skip to main content
14,429,974 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi, I am stuck on a problem that requires me to come up with a way to calculate the largest side perimeters of different shapes. I am kind of confused on how to even start with it tbh.

This is some of the code.

public class PerimeterAssignmentRunner {

public double getPerimeter (Shape s) {

double totalPerim = 0.0;

Point prevPt = s.getLastPoint();

for (Point currPt : s.getPoints()) {

double currDist = prevPt.distance(currPt);

totalPerim = totalPerim + currDist;

prevPt = currPt;


// totalPerim is the answer

return totalPerim;


The package was provided with points given in another file (don't know the exact the terminology).

What I have tried:

double largestSide = 0;
Point prevPt = s.getLastPoint();
for(Point currPt:s.getPoints())
Updated 11-Nov-18 21:00pm

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Work out the length of each segment, that is basic Pythagoras: BBC - GCSE Bitesize: The length of a line segment[^]
Then all you have to do is work out the longest...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100