1 package shapes; 2 /* 3 * This program uses inscribed circles to calculate the area of the yellow space in a canvas. 4 */ 5 6 public class YellowSpace { 7 public static void main(String[] args) 8 { 9 int bigGraySquareLength = 400; 10 int largeYellowDiamondDistance = 60; 11 int smallGraySquareDistance = 30; 12 int smallYellowDiamondDistance = 15; 13 14 SSquare bigGraySquare = new SSquare(bigGraySquareLength); 15 // System.out.println(bigGraySquare.area()); --> checks area 16 SCircle dot1 = bigGraySquare.inscribingCircle(); 17 dot1.setRadius((int) dot1.radius() - largeYellowDiamondDistance); //inscribing circle is shrunk by the largeYellowDiamond's distance to the midpoint 18 SSquare largeYellowDiamond = dot1.inscribingSquare(); // largeYellowDiamond is inscribed in the square 19 // System.out.println(largeYellowDiamond.area()); --> checks area 20 21 SCircle dot2 = largeYellowDiamond.inscribingCircle(); // new circle is inscribed in largeYellowDiamond 22 dot2.setRadius((int) (dot2.radius() - smallGraySquareDistance)); // circle is shrunk to smallGraySquare's distance from the midpoint of the largeYellowDiamond 23 SSquare smallGraySquare = dot2.inscribingSquare(); // smallGraySquare is inscribed into the circle 24 //System.out.println(smallGraySquare.area()); --> checks area 25 26 SCircle dot3 = smallGraySquare.inscribingCircle(); // new circle is inscribed in smallGraySquare 27 dot3.setRadius((int) (dot3.radius() - smallYellowDiamondDistance)); // circle is shrunk by smallYellowDiamond's distance to the midpoint of the smallGraySquare 28 SSquare smallYellowDiamond = dot3.inscribingSquare(); // smallYellowDiamond is inscribe in the circle 29 //System.out.println(smallYellowDiamond.area()); --> checks area 30 31 double yellowArea = ((largeYellowDiamond.area() + smallYellowDiamond.area()) - smallGraySquare.area()); 32 33 System.out.println("Area of yellow space " + yellowArea + " mm"); 34 } 35 } 36