I've been tinkering with this for a while but I can't seem to get rid of those last two errors. Some help would be wonderful, thank you. ^_^
This link has what it's supposed to look like, click on the Sierpinski button to see.
Sierpinski Triangle
Errors:
Sierpinski.java:53: cannot find symbol
symbol : variable dx
location: class Sierpinski
int x4 = x - dx / 2;
^
Sierpinski.java:54: cannot find symbol
symbol : variable dy
location: class Sierpinski
int y4 = y - dy / 2;
^
2 errors
import java.awt.*; import java.awt.Color; import javax.swing.JFrame; import java.awt.Polygon; import java.util.Random; public class Sierpinski extends Canvas { public void paint( Graphics z ) { Random flippin_tables = new Random(); for( int n = 1; n <= 50000; n = n+1 ) { int x = 512; int y = 382; int x1 = 512; int y1 = 109; int x2 = 146; int y2 = 654; int x3 = 876; int y3 = 654; int r = flippin_tables.nextInt(255); int g = flippin_tables.nextInt(255); int b = flippin_tables.nextInt(255); Color COOL = new Color(r,g,b); z.setColor(COOL); z.drawLine(x,y,x,y); for( int q = 1; q <= 100000; q = q+1 ) { } int oh_MY = 1 + flippin_tables.nextInt(3); if ( oh_MY == 1 ) { int dx = x-x1; int dy = y-y1; } if ( oh_MY == 2 ) { int dx = x-x2; int dy = y-y2; } if ( oh_MY == 3 ) { int dx = (x-x3); int dy = y-y3; } int x4 = x - dx / 2; int y4 = y - dy / 2; z.drawLine(x4,y4,x4,y4); z.drawString("Sierpinski Triangle", 462,484); } } public static void main(String[] args) { JFrame win = new JFrame("Sierpinski"); win.setSize(1024,768); win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); win.add( new Sierpinski() ); win.setVisible(true); } }