I have to make the game Flood-It for a project and I'm struggling with the blocks you have to make.

This is my code so far, basically all I have done is drawn random colored blocks to see if I can do it, now the problem I have is how do I assign say grid[0][0] one of the random colors. In the end I want every block that was drawn to be assigned to a different grid[i][j].

Picture of what I basically want if my words did not make sense:Code:`public class Colours {`

public static void main(String[] args) {

int N = 5;

double xpos = 0.0;

double ypos = 0.0;

double size = 0.05;

double[][] grid = new double[N][N];

for (int i = 0; i < N; i = i + 1) {

for ( int j = 0; j < N; j = j + 1) {

grid[i][j] = 5;

System.out.println(i + " " + j + " " + grid[i][j]);

}

}

StdDraw.setCanvasSize(500,500);

for (double c = 0.0; c < 1; c = c + size) {

for (double z = 0.0; z < 1; z = z + size) {

int rn = (int) (Math.random() * 6 + 1);

if (rn == 1) {

StdDraw.setPenColor(StdDraw.RED);

}

if (rn == 2) {

StdDraw.setPenColor(StdDraw.BLUE);

}

if (rn == 3) {

StdDraw.setPenColor(StdDraw.ORANGE);

}

if (rn == 4) {

StdDraw.setPenColor(StdDraw.GREEN);

}

if (rn == 5) {

StdDraw.setPenColor(StdDraw.GRAY);

}

if (rn == 6) {

StdDraw.setPenColor(StdDraw.PINK);

}

StdDraw.filledSquare(xpos, ypos, size/2);

xpos = xpos + size;

}

xpos = 0.0;

ypos = ypos + size;

}

}

}

Attachment 4641

I want this to be for every block that has been drawn.