[B] the objective is to sort the circles based on color in each row. I cannot get the color pattern to run and then I need to display the colored circles across the applet
// GraphicsLab06st.java
// This is the Student Version of the Lab11GRFX06 assignment.
import java.awt.*;
import java.applet.*;
import java.util.*;
public class GraphicsLab06st extends Applet
{
public void paint(Graphics g)
{
int circleCount = 40;
Circles circles = new Circles(g,circleCount);
}
}
class Circles
{
private int circleCount;
private Random rnd;
private Color randomColor;
private int colorRow;
private int redCount, greenCount, blueCount;
public Circles(Graphics g,int c)
{
rnd = new Random(12345);
circleCount = c;
redCount = 1;
greenCount = 1;
blueCount = 1;
drawSquares(g);
for (int k = 1; k <= circleCount; k++)
drawRandomCircle(g);
}
public void drawSquares(Graphics g)
{
g.setColor(Color.red);
g.fillRect(10,100,30,30);
g.setColor(Color.green);
g.fillRect(10,250,30,30);
g.setColor(Color.blue);
g.fillRect(10,400,30,30);
}
public void drawRandomCircle(Graphics g)
{
int wxtft = 10;
getRandomColor();
g.setColor(randomColor);
g.fillOval (wxtft,colorRow,30,30);
}
public void getRandomColor()
{
// red
int r = rnd.nextInt(256);
// green
int g = rnd.nextInt(256);
// blue
int b = rnd.nextInt(256);
randomColor = new Color (r,g,b);
if (r > g && r > b )
{
colorRow = 100 ;
}
if (g > b && r < g)
{
colorRow = 250 ;
}
if (b > r && g < b)
{
colorRow = 400;
}
}
}