Fall 2013, Lab 7

**Assignment: Part 1.** Write a method *drawHline* which
draws a horizontal line of a given color. This method should have
the following 5 input parameters:

- an image (of type JRaster);
- starting x-coordinate;
- ending x-coordinate;
- y-coordinate;
- color of the line.

**Assignment: Part 2.** Write a method *drawVline* which draws a vertical line of a given color.
This method should have the following 5 input parameters:

- an image (of type JRaster);
- x-coordinate;
- starting y-coordinate;
- ending y-coorinate;
- color of the line.

**Assignment: Part 3.** Write a method *drawLine* which
draws a generic line of a given color. This method should have the
following 6 input parameters:

- an image (of type JRaster);
- starting x-coordinate;
- starting y-coordinate;
- ending x-coordinate;
- ending y-coordinate;
- color of the line.

**Hint:** A line which connects points (x_{1},
y_{1}) and (x_{2}, y_{2}), with
x_{1} < x_{2}, can be described as follows:

- When the line is more horizontal than vertical, i.e., when
|y
_{2}− y_{1}| <= |x_{2}− x_{1}|, then the line can be described by the formulay = y where the slope s is equal to the ratio (y_{1}+ s * (x − x_{1}),_{2}− y_{1})/(x_{2}− x_{1}). To draw the line, for each x from the starting x-coordinate to the ending x-coordinate, compute the corresponding value y and draw the point with coordinates (x, y). - When the line is more vertical than
horizontal, i.e., when |y
_{2}− y_{1}| > |x_{2}− x_{1}|, then the line can be described by the formulax = x where the slope S is equal to the ratio (x_{1}+ S * (y − y_{1}),_{2}− x_{1})/(y_{2}− y_{1}). To draw the line, for each y from the starting y-coordinate to the ending y-coordinate, compute the corresponding value x and draw the point with coordinates (x, y).

**Assignment: Part 4.** Draw a house -- as in Lab 6 -- using your methods.

**Testing:** test each of your methods by calling it, from the
*main* program, at least three times, with different values of
the corresponding parameters. As instructed in class, test each
program on the boundary values of each parameter, and on some
intermediate value (e.g., randomly selected). For example, for a
horizontal line, y-coordinate can be from 0 to 199, so test it for
y = 0, for y = 199, and for some intermediate value y.

**When it is due.** The program is due at the beginning of the
first lab section on the week of October 21, i.e.:

- on Monday October 21 for those who attend Monday-Wednesday labs, and
- on Tuesday October 22 for those who attend Tuesday-Thursday labs.