March 5th, 2013, 12:54 PM
c. (10 points) Instead of using *s, use line segments for the plot. You must use a loop, not just draw the lines using separate drawLine() calls. No asterisks will be displayed. To draw a line, you need two points. You will have to remember the the first point's place in order to draw the line between the first and second point. Then you have to draw a line from the second to the third point.
This is sort of a fence post problem. Set up the first point with coordinates oldX and oldY before the loop. In the loop generate newX and newY for the second point. Draw the line. Give oldX and oldY the values of newX and newY. Continue looping.
This is what I have to do for my homework.
This is the code I already have and it's not working.
I'm not sure how to make it so the line loops replacing the previous coordinates.
March 5th, 2013, 02:43 PM
You forgot to post the code. Please remember to use code tags when you post the code.
From you description, it sounds like you can do it like this:
You do have an origX and origY variable?
oldX = newX;
oldY = newY;
March 5th, 2013, 03:34 PM