Today you may work alone *OR* with a partner for some or all of the lab.
I would suggest, however, that each person make sure they can fully
do exercise 1. all by yourself and understand it completely.
Required Working Style for Today's Lab:
- From beginning to end you will work in a folder which contains all your work for today's lab.
- Before you leave, you will email me all the files necessary to run your application.
- Download the a version of the code from this morning ...
... and enhance in the following ways:
- setup a Scanner
- remove the p2 array assignment
instead, read all coordinates from an input file into the 2 dimensional array;
all the x's to 0-th row and all y's to 1-th row.
Don't forget to use the first value read
to construct your array to be of the proper size to hold all the values you will read
Don't bother to prompt the user with SOPf's unless you just want to.
Your input file should have the following format.
n, the number of points to follow
x1 y1
x2 y2
x3 y3
......
xn yn
Here's an example of what that would look like for a simple triangular shape.
3
1.8 1
1 10.5
10 10
(Here's one that has coord's from this morning's polygon:
ProfDalePoly.txt)
Make an input file with more points(miniumum 12) and which will be an interesting (I have graph paper)
shape when drawn.
Notice there are no comma's and nothing except NUMBERS in the file.
Newlines & spaces do not matter to the computer but they do to ME, the human,
and so please make these files clearly understandable.
- Read your own input file & print out all coordinates in the following format.
Notice all fields are formatted for width so that numbers 'line up' in a readable manner.
Also there is extra space between the ()'s and the ,'s and the numbers. Do not add extra newlines;
one per set of coordinates is plenty.
[0] = ( 1.8 , 1.0 )
[1] = ( 1.0 , 10.5 )
[2] = ( 10.0 , 10.0 )
Did you remember to re-direct standard input ?
- Does your polygon look like you expected it to? Show me!
-
Go on from here and HAVE FUN.
Try some of the following...
- use circle & square
- use ellipse & rectangle
- use line
- use loops to draw the light gray lines of the grid paper on StdDraw
- change pen radius
- change background color
- use text (and set the font!!!!)
- put outlines around filled shapes
- Draw a whole... scene of shapes. (Halloween is coming)
- changing the X & Y scale allows you to draw using different coords; when/why is this helpful?
- What about a loop placing randomly shaped, colored, and placed ovals all over the window
-
what else ?
-
Book Exercises - start with whichever you like
- 1.5.19 straight lines
- 1.5.25 uh... quilt squares
and.... - 1.5.37 the whole quilt, (-:
- 1.5.29 terrain analysis
- 1.5.30 histogram
- 1.5.31 spirographs