CoSc 200 Laboratory #5
Repetition
Your goal is to use loops, separate classes, and private methods to make checkerboard patterns and stars at randomly generated centers, radii, and numbers of points. You may work on these programs in either order.
A square checkerboard pattern appears initially. A user press, drag, and release produces a new checkerboard pattern where the dimensions of the individual squares are determined by the user's press and release points. The colors should alternate, just like on a checkers or chess board, and there should be grid lines that are 2 to 4 pixels thick. You are free to choose different colors for the squares and grid lines, but make sure that they are contrasting. The user should be prevented from choosing a size that is too small (some color should appear between the grid lines). Good design principles require that the creation of a checkerboard pattern either occur in a private method or as a constructor of a class separate from the program class.
Here
is some trigonometry that may be useful in planning how to design stars. The
relationship between the Cartesian and polar coordinates of a point can be
expressed
x = r cos(θ)
y = r sin(θ)
where the angle is measured in radians. The relationship between measuring angles in degrees and radians can be expressed
<angle in radians> = <angle in degrees> / 180 * π
| Value | Feature |
| Style and Design | |
| 3 |
Descriptive comments, good names, good use of constants, and appropriate formatting. |
| 2 |
Good use of while statements. |
| 2 |
Appropriate class or private method for checkerboard construction. |
| 1 |
Appropriate private method for stars introductory display. |
| 2 |
Appropriate class, constructor, and parameters for stars. |
| Correctness | |
| 2 |
Checkerboard has alternating colors. |
| 2 |
Checkerboard has grid lines. |
| 1 |
Checkerboard has can be sized by user. |
| 1 |
User prevented from choosing sizes that are too small to be seen on checkerboard. |
| 1 |
Inital star and instructions. |
| 2 |
Randomly generated stars. |
| 1 |
Refresh on mouse exit. |
As with previous lab assignments, you should submit your ".java" files through Blackboard. You can either add these files separately before you submit, or you can first zip together these files into a single ".zip" file and submit this single ".zip" file.
Submission Deadline: 3:00pm on Tuesday, February 7. Note that once you submit, it is impossible to submit a revision.
Resubmission and Late Submission Deadline: 3:00pm on Tuesday, February 14. A 5 point penalty will be assessed for a resubmission or late submission.
Good luck and have fun!