Sad Mask
Would you be so kind as to disable your ad-blocker on BasilMarket please? Your support is greatly appreciated.

Help with Java Programming

Non-MS Tech Forum Talk about computer and tech topics

JamesInNinja Level 70 Windia Chief Bandit
So I'm fairly new to object orientated Java programming and our teacher wants us to creat a rectangle, and any other 5+ Sided shape and my rectangle and that shape are very messed up.. I'm not sure what order to put my points in, so if someone can help that would be great. The rectangles code and how it looks are here:

[url=]Code [/url]Picture

And the other 5+ sided (real known shape)

[url=]Code [/url] Picture

thank you for any help!
Posted: March 2012 Permalink


In general, you should define a polygon by defining the points clockwise or counterclockwise. According to the API, a line segment will form between the last point and the first, so you have to take that into account.
Mar 07 2012
JamesInNinja Level 70 Windia Chief Bandit
Alright. I kind of get that, anyway you know what I can do to my code to make it work correct. I'll change my points to clockwise.
Mar 08 2012
Make the last y-coordinate be yPosition.
Mar 08 2012
JamesInNinja Level 70 Windia Chief Bandit
I love you Any idea on helping me with my other shape, I'm tinkering on my own hoping to strike gold soon!
Mar 08 2012
I inputted the data into a very old program of mine and the following came out that SHOULD make it work:

50 0
75 -15
100 0
100 8
75 15
50 8

Unfortunately, converting that back to code would take quite a bit of time.

Again, I'm not certain if the output is correct since I haven't tested it for a while, but the general goal is to form a "convex hull" in the way you form your polygon. Otherwise, it might have difficulty forming the correct polygon.
Mar 08 2012

Become a member

Signup or login to join the conversation.