CS 1401 Introduction to Computer Science
Fall 2013, Lab 7

Objective. The purpose of this lab is to practice defining and testing methods.

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:

Assume that the ending x-coordinate is larger than or equal than the starting x-coordinate. Return an error message if the line is outside the standard JRaster 200 x 200 box.

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:

Return an error message if the line is outside the standard box 200 x 200.

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:

Return an error message if the line is outside the standard box 200 x 200.

Hint: A line which connects points (x1, y1) and (x2, y2), with x1 < x2, can be described as follows:

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.: