First of all, I'd like to apologize if this is not in the correct section, this is my first post to the board. If I was wrong to post here, I welcome any criticism so long as you also teach me something
Anyways, I'm currently working on a practice problem from the textbook "Java - How to Program (9th edition)" at the end of chapter 4. (Fig 4.20)
The problem requires that I use 4 seperate while loops (one for each corner) to drawing 15 lines coming from each corner of the panel in a manner that would resemble a hand fan.
This is a typical case of a problem that should take no more than 5 minutes to complete yet for some reason has become quite an ordeal for me.
The issue is that while the top corners display in the manner that the book requires, the bottom ones seem to have a bit of an offset and do not end up meeting the top ones (eg: bottom left fan should extend so that each line's endpoint connects with the endpoints of the top right fan, meeting halfway.)
I've removed the bottom-right fan for the time being, to make it easier to look at.
Here are my two top corners' while loops:
int x; int y; int count; int width = getWidth(); // total width int height = getHeight(); // total height x = 0; y = height; count = 1; while(count <= 15) { g.drawLine(0, 0, x, y); x += width / 15; y -= height / 15; ++count; } // end while x = width; y = height; count = 1; while(count <= 15) { g.drawLine(width, 0, x, y); x -= width / 15; y -= height / 15; ++count; } // end while
Here is the while loop for the bottom left-corner:
x = 0; y = 0; count = 1; while(count <= 15) { g.drawLine(0, height, x, y); x += width / 15; y += height / 15; ++count; } // end while
Here is a picture of what currently displays:
Capture.jpg
Hopefully I've provided enough information about my problem. Although I'm 99% sure that the problem does not lie elsewhere in my code, 1% is a risk I don't want to take so here are pastebin links to my frame and panel classes (I already had them in pastebin from another board, and am unsure of how clean code snippets appear on this board so I don't want to take chances putting it all up here in case it causes a mess).
Just add these to the end of pastebin(dot)com/
x703CsGv
Yi1cuNZY
Thank you