public static void flagOfLiberia(Graphics g) {
Expo.setBackground(g,Expo.black);
for (int d = 1; d <= numDots; d++) {
int x = Expo.random(0,1000);
int y = Expo.random(0,650);
if (x < 300 && y < 300)
Expo.setColor(g,Expo.darkBlue);
else if (y % 100 < 50)
Expo.setColor(g,Expo.red);
else
Expo.setColor(g,Expo.white);
drawDot(g,x,y);
Expo.setColor(g,Expo.white);
Expo.fillStar(g,150,150,100,5);
}
showName(g,"Liberia");
}
The above should be at least a little improvement. I used a modulus (%) to check every multiple of 100, seeing if the remainder is less than or greater than 50. If you desire a cutoff at 650, then a single if
statement can be added before the modulus to check that y
is below the threshold.