Need help writing code for generating random triangles.

You will have the following functions (no violation of these interfaces) and you may have others, as needed:
− public static void GenerateRandomTriangles(int numTriangles)
to create a file RandomTriangles.dat having the following format (including some comments like the ones
shown below) with random integer coordinates (x, y) of the three vertices of a triangle. Each x and y will be a
random integer in the range 0 <= x, y < 150. (Use seed for random numbers.)
5 //numTriangles; each line below gives integer coordinates (x, y) of vertices of a triangle
( 20, 100) ( 25, 88) (112, 99)

Here is what I have so far:
public class TestTriangleType

    public static void GenerateRandomTriangles(int numTriangles)
    int x1,y1,x2,y2,x3,y3 = 0
    Random randomInt = new Random(0);
    x1 = randomInt.nextInt(150);
    y1 = randomInt.nextInt(150);
    do x2 = randomInt.nextInt(150);
       y2 = randomInt.nextInt(150);
    while (!(x1 == x2) && (y1 == y2);
    do x3 = randomInt.nextInt(150);
       y3 = randomInt.nextInt(150);
    while (!(x2 == x3) && (y2 == y3);     

Line 11, you need to compare x3,y3 with x1,y1 as well because there is a possibility that x1,y1 is the same as x3,y3.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.