Basic HTML version of Foils prepared June 5 99

Foil 18 First Programming Lab - Patterns of Shapes

From Java Language in the Computer Science Curriculum ADMI Tutorial Duluth Minnesota -- June 3 99. by Geoffrey C. Fox


1 import java.applet.Applet;
2 import java.awt.*;
3 public class Pattern extends Applet
4 { public void paint( Graphics g )
5 {
6 // The variable x represents where to draw in the x direction (to the right)
7 int x = 0;
8 // sets the background to be white and drawing color to be magenta
9 setBackground ( Color.white);
10 g.setColor( Color.magenta );
11 // draw a sequence of 6 circles of size 40, evenly spaced
12 for ( int i = 0; i < 6; i++ )
13 { x = x + 50;
14 // each circle has y = 20, width and height = 40 pixels
15 g.fillOval ( x, 20, 40, 40 );
16 } } }
17

in Table To:


© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sat Jun 5 1999