introductionToProgramming/week5/Circles.java
Daniel Bulant a475669d50
week 4 + 5
2025-09-29 17:28:00 +02:00

27 lines
729 B
Java

package week5;
import common.StdDraw;
public class Circles {
public static void main(String[] args) {
var circleCount = Integer.parseInt(args[0]);
var pBlack = Double.parseDouble(args[1]);
var minRadius = Double.parseDouble(args[2]);
var maxRadius = Double.parseDouble(args[3]);
StdDraw.setScale();
StdDraw.clear();
for(var i = 0; i < circleCount; i++) {
if(Math.random() < pBlack) {
StdDraw.setPenColor(StdDraw.BLACK);
} else {
StdDraw.setPenColor(StdDraw.WHITE);
}
var radii = Math.random() * (maxRadius - minRadius) + minRadius;
var posX = Math.random();
var posY = Math.random();
StdDraw.filledCircle(posX, posY, radii);
}
}
}