import javax.swing.*; import java.awt.*; public class TestGeometricHeirarchy { public static void main(String[] args) { JTextArea textarea; JScrollPane scrollpane; textarea = new JTextArea(20,100); textarea.setLineWrap( true ); textarea.setFont( new Font("Courier",Font.BOLD,14) ); scrollpane = new JScrollPane(textarea); Circle circle = new Circle(1); textarea.append("A circle " + circle.toString()); textarea.append("\nA circle " + circle); //same as explicit call of toString() textarea.append("\n The radius is " + circle.getRadius()); textarea.append("\n The area is " + circle.getArea()); textarea.append("\n The color is " + circle.getColor()); if (circle.isFilled()) textarea.append("\n it's filled"); else textarea.append("\n it's not filled"); textarea.append("\n The date is " + circle.getDateCreated()); Rectangle rectangle = new Rectangle(2, 4); textarea.append("\n\nA rectangle " + rectangle.toString()); textarea.append("\n The area is " + rectangle.getArea()); textarea.append("\n The perimeter is " + rectangle.getPerimeter()); textarea.append("\n The color is " + rectangle.getColor()); if (rectangle.isFilled()) textarea.append("\n it's filled"); else textarea.append("\n it's not filled"); textarea.append("\n The date is " + rectangle.getDateCreated()); /* Ellipse ellipse = new Ellipse(2, 4); textarea.append("\n\nAn ellipse " + ellipse.toString()); textarea.append("\n The area is " + ellipse.getArea()); textarea.append("\n The perimeter is " + ellipse.getPerimeter()); textarea.append("\n The color is " + ellipse.getColor()); if (ellipse.isFilled()) textarea.append("\n it's filled"); else textarea.append("\n it's not filled"); textarea.append("\n The date is " + ellipse.getDateCreated()); */ JOptionPane.showMessageDialog(null, scrollpane, "Geometric Test", JOptionPane.PLAIN_MESSAGE); } }