Add a shiftAndPrint
method to PointPrinter
that
moves a point right 3, up 3, left 6, down 6, right six, up 3, and left
3, printing the result at each step.
Add a shiftAndPlot
method to PointPrinter
that
moves a point right 3, up 3, left 6, down 6, right six, up 3, and left
3, plotting the result at each step. Write a program that reads in the
point and uses the helper to plot the point at each position.
Write a program, Grid.java
, that prints out a 3 by 3 grid
of points on the plane. Make the spacing in the grid one
unit.
Write a program, Grid.java
, that prints out a 3 by 3 grid
of points on the plane. Input the spacing in the grid and the
center point in the grid.
Write a program, Smiley.java
that draws a smiley face by
plotting points appropriately.
Write a program, Initials.java
, that draws your initials by
plotting points appropriately.
Using the techniques from Experiment J2.8, draw your name in a rainbow of colors. (Your name will appear in each color.)
In this session, you learned about six methods provided by
java.awt.Graphics
for drawing basic shapes:
drawString
, drawLine
,
drawRect
, drawOval
,
fillRect
, and fillOval
. Are these
all that's available? Consult the Java documentation and write
short summaries of the other drawing methods.
Instead of the rainbow-drawing technique from Problem J2-G, you might
want to draw each letter in a different color. However, this makes
it necessary for you not only to change the color before drawing each
letter, but also to determine the correct place to draw each letter.
Does Java give you the tools for doing so? Yes. There is a
FontMetrics
class that helps you determine the width
of strings. Read the documentation on that class and write instructions
that a classmate could use to write his or her name with each letter in a
different color.
[Front Door] [Introduction] [Code]
Copyright (c) 1998 Samuel A. Rebelsky. All rights reserved.
Source text last modified Tue Oct 26 12:55:42 1999.
This page generated on Tue Oct 26 15:38:00 1999 by Siteweaver.
Contact our webmaster at rebelsky@math.grin.edu