- #1
Hiche
- 84
- 0
Code:
import java.awt.Color;
public class ChangingColor
{
public static void main(String[] args)
{
while (true)
{
int R = (int) (Math.random() * 256);
int G = (int) (Math.random() * 256);
int B = (int) (Math.random() * 256);
Color randomColor = new Color(R, G, B);
StdDraw.setPenColor(randomColor);
StdDraw.filledSquare(.5, .5, .25);
StdDraw.show(500);
}
}
}
Okay, this works. But is there another way to code this using only the StdDraw class? I used Color, but we haven't covered this a lot.