Drawing it out really helps if you are struggling.
What I did was when I was calling the method, I looped through my list of coordinates and made the vertexes. This caused each vertex to be different than what I previously had for squares, so I drew it out using the new vertexes. I then had a helper method createSides(filewriter, sides) that would write out all the side rectangles for me, since no matter what shape it was they were rectangles. Then, all I had to do was draw the top and bottom seperately, making it easily extensible if needed.
Use this presentation for references