Java: Writing a program that calculates midpoints based on randomly picking 2 out of 3 verticies
<p>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. My biggest problem is that I don't know how to pick a point at random, and I also don't know how to go from taking the midpoint of two of the original points to taking the midpoint of the old midpoint and an original point. This is the code I have so far (please feel free to point out any mistakes I made in the code I have!):</p>

<pre><code>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_CLOSE);
        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)
    {

        points.add(p);
    }


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

        int i = 0;

        while (i &lt; 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;
    }

}
</code></pre>
