CS 120
Fall 2016, Instructor: Jeffrey
Horn
Assignment
7: "Graph Paper"
Handed out:
Tuesday, October 25, 2016
Due:
Monday, November 7, 2016
Purpose: Learn
- More Java graphics
- More for loops
- Nested loops
- Private methods that take Graphics objects
Example Code: (in class)
DETAILS:
-
Make two methods: one that draws traditional (i.e., solid lines) graph
paper, and one that draws "Dortmund style" graph paper.
-
Both types of graph paper should be annotated along the left and the top
margins, with numbers indicating pixels.
-
Here are the method signatures you MUST use!
- private void drawQuadrilleGraphPaper(Graphics g, int separation, int
thickness)
- private void
drawDortmundGraphPaper(Graphics g, int separation, int dotsize)
- Here is what I mean by
Dortmund Graph Paper:
-
When I was on a conference trip to the Kongresszentrum
Westfalenhallen (a
conference hotel in Dortmund, Germany), the conference center gave out
free pads of notepaper. I was delighted to see that the paper was not
horizontal rule that we are accustomed to (e.g., in legal pads, typical
school notbooks, journal books, etc.), but more two-dimensional, like
the quadrille-ruled notebooks I use for my research journals. But the
"Dortmund paper" represents a compromise: instead of the heavy 2-D
lines that many people seem to find distracting (but which I like), the
paper has a very light touch when it comes to "rulings". The paper has
a grid of light gray dots. Please see the handout in class.
-
Your challenge is to draw a grid just like this, to cover the whole
page. There are a number of ways to do this (e.g., nested loops, or a
single loop with an if-then statement in the body to "wrap around" like
a typewriter does, or a single-loop with the "remainder operator"
(a.k.a., the "modulus operator"), "%", etc.).
-
It must use gray dots (circles), not black ones.
-
It does NOT have to have any of the heading material (e.g., hotel name,
logo, blank horizontal lines, etc.) of footer text that is on the
example sheet.
- STYLE: The usual (main comment, descriptive variable names,
describe var.s in comments, comment all logical groups of code such as
methods, loops, if-then's).
- TURN IN BY EMAIL: Send me your
java code. Use SUBJECT LINE: "CS120: A7 ..."
GRADING: TOTAL: 100 pts.
EXTRA CREDIT CHALLENGES:
- Annotations
along the left and the top margins, with numbers indicating pixels.
- Logarithmic graph paper.
- Hexagonal graph paper!