What I want to do is start with three points that make an equilateral triangle. My code should pick two of the three points at random, calculate a midpoint (m), and plot it. Then from the midpoint m it generated, the code will pick another one of the three original points at random and compute a new midpoint (m2). The last step should be repeated 10,000 times. I'm just starting out with Java and am really lost. This is the code I have so far (please feel free to point out any mistakes I made in the code I have!):


import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.Graphics;
import java.awt.Dimension;

public class Game
{
static final int HEIGHT = 500;
static final int WIDTH = 500;

public static void main(String[] args)
{
JFrame frame = new JFrame("The Game");
Board board = new Board(WIDTH, HEIGHT);
Point p1 = new Point(0,0);
Point p2 = new Point(500, 0);
Point p3 = new Point(0, 250);

frame.setSize(WIDTH, HEIGHT);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);
frame.setContentPane(board);

board.addPoint(p1);
board.addPoint(p2);
board.addPoint(p3);

frame.pack();
frame.setVisible(true);

}
}

class Board extends JPanel
{
public Board(int h, int w)
{
setPreferredSize(new Dimension(w, h));
}

public void addPoint(Point p)
{
ArrayList <Point> point = new ArrayList();
points.add(p);
}


public void paint(Graphics g)
{
super.paint(g);

int i = 0;

while (i < 10000)
{
board.add();
i++;
}

}
}

class Point
{
int x;
int y;

public Point(int x, int y)
{
x = this.x;
y = this.y;
}

private static Point midPoint(Point p1, Point p2)
{
return new Point((p1.x + p2.x)/2, (p1.y + p2.y)/2);
}

public double getX()
{
return x;
}

public double getY()
{
return y;
}

}