This assignment gives the student experience creating fat diagonal lines using fillOval. If the student ponders this situation, the student will realize that it is not all that easy to create fat lines which are diagonal. If the student were to desire fat horizontal or vertical lines, it would be easy for the student to simply use fillRect, but for fat diagonal lines, things are a little trickier.

The student will create an applet like the one shown here.
This activity provides the student the opportunity to create fat diagonal
lines.
EXAMPLE: |

x |

__ASSIGNMENT:__

Here's the method to make a fat diagonal line:

public void drawDLine(Graphics g, int startx, int starty, int endx, int endy){ float xinc=(float)(startx-endx)/(float)45.0; float yinc=(float)(starty-endy)/(float)45.0; float currX=startx; float currY=starty; for(int c=0; c < 45; c++){ g.fillOval(Math.round(currX),Math.round(currY),5,5); currX-=xinc; currY-=yinc; } }

The student can call it using this line:

drawDLine(g, 100, 10, 190, 100);

The first parameter is the graphics reference, the second is the starting x point, the third is the starting y point, the fourth is the ending x point, and the last is the ending y point.