1 package NPW; 2 3 import painter.SPainter; 4 import shapes.SCircle; 5 import shapes.SRectangle; 6 import shapes.SSquare; 7 import javax.swing.*; 8 import java.awt.*; 9 import java.util.Random; 10 import java.util.Scanner; 11 12 public class Stella { 13 private void paintTheImage() { 14 15 int int1 = getNumber("Amount of Squares?"); 16 int int2 = 700/int1; 17 int int3 = 0; 18 19 //painter setup 20 SPainter yeet = new SPainter("Stella", 800, 800); 21 SSquare paint = new SSquare(700); 22 Color color = randomColor(); 23 Color color2 = randomColor(); 24 25 26 // The % sign is a modulus operator (basically the remainder will be left when dividing) 27 while (int3 < int1) { 28 if (int3%2 == 0) { 29 yeet.setColor(color); 30 } else{ 31 yeet.setColor(color2); 32 } 33 yeet.paint(paint); 34 35 // int is required according to intellij 36 paint.resetSide((int) (paint.side()-int2)); 37 int3 = int3 +1; 38 // As long as int3 is less than whatever value you give it will keep painting squares 39 } 40 } 41 42 private static Color randomColor() { 43 int r = (int)(Math.random()*256); 44 int g = (int)(Math.random()*256); 45 int b = (int)(Math.random()*256); 46 return new Color(r,g,b); 47 48 } private static int getNumber(String prompt) { 49 String nss = JOptionPane.showInputDialog(null,prompt+"?"); 50 Scanner scanner = new Scanner(nss); 51 return scanner.nextInt(); 52 } 53 54 55 56 public Stella() { 57 paintTheImage(); 58 } 59 60 public static void main(String[] args) { 61 SwingUtilities.invokeLater(new Runnable() { 62 public void run() { 63 new NPW.Stella(); 64 } 65 }); 66 } 67 }