Digg Master Cheater
Reputation: 0
Joined: 14 Mar 2007 Posts: 362 Location: Houston, Texas
|
Posted: Sun May 03, 2009 9:56 pm Post subject: Simple Java program help |
|
|
Can anyone help me with this? Below is my code for a program
| Code: | // Lab11ast.java
// This is the Student Version of the Lab11a assignment.
import java.awt.*;
import java.applet.*;
import java.util.*;
import java.util.Random;
public class Prog extends Applet
{
Color myColors[];
Thread runner;
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,k);
}
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 k)
{
if(circleCount<=17)
Random r = new Random();
Color red = new Color(r.nextInt(256),r.nextInt(256),r.nextInt(256));
g.setColor(red);
g.fillOval(k*50+10,100,30,30);
Color green = new Color(r.nextInt(256), r.nextInt(256),r.nextInt(256));
g.setColor(green);
g.fillOval(k*50+10,250,30,30);
Color blue = new Color(r.nextInt(256),r.nextInt(256), r.nextInt(256));
g.setColor(blue);
g.fillOval(k*50+10,400,30,30);
}
public void getRandomColor(Graphics g)
{
}
|
And the intended output is attached. Can anyone point me in the right direction?
| Description: |
|
| Filesize: |
39.27 KB |
| Viewed: |
2817 Time(s) |

|
_________________
13x Bera Dexless DrK
I'm all open for HT runs, PM Me. |
|