1 /* 2 This program affords opportunities to explore the computational solution to simple geometrical problems 3 by means of the construction and use of basic shapes. 4 Made By Miguel Cruz | Lab 4 5 */ 6 7 package shapes; 8 9 import painter.SPainter; 10 11 import javax.swing.*; 12 import java.awt.*; 13 14 public class ShapesThing { 15 //Global 16 SPainter paintBrush = new SPainter("ShapesThing",600,600); 17 SSquare square = new SSquare(400); 18 SCircle disk = square.inscribingCircle(); 19 SSquare diamond = disk.inscribingSquare(); 20 21 public void paintTheImage(){ 22 23 paintBrush.setColor(Color.BLACK); 24 paintBrush.setBrushWidth(2); 25 paintBrush.draw(square); 26 paintBrush.draw(disk); 27 paintBrush.setColor(Color.BLUE); 28 paintBrush.tl(45); 29 paintBrush.paint(diamond); 30 } 31 public void printShapeData(){ 32 33 System.out.println("-------------------------------------------------"); 34 System.out.println("Square = " + square.toString()); 35 System.out.println("Area of the square = " + square.area()); 36 System.out.println("Perimeter of the square = " + square.perimeter()); 37 System.out.println("Diagonal of the square = " + square.diagonal()); 38 System.out.println("-------------------------------------------------"); 39 40 System.out.println("Disk = " + disk.toString()); 41 System.out.println("Area of the disk = " + disk.area()); 42 System.out.println("Perimeter of the disk = " + disk.perimeter()); 43 System.out.println("-------------------------------------------------"); 44 45 System.out.println("Diamond = " + diamond.toString()); 46 System.out.println("Area of the diamond = " + diamond.area()); 47 48 } 49 50 51 52 53 54 55 public ShapesThing() { 56 paintTheImage(); 57 printShapeData(); 58 } 59 60 public static void main(String[] args) { 61 SwingUtilities.invokeLater(new Runnable() { 62 public void run() { 63 new ShapesThing(); 64 } 65 66 }); 67 } 68 } 69 70 71