import java.applet.Applet; import javax.swing.*; import java.awt.Graphics; import java.awt.*; public class WorkSpaceViewer extends Applet { private WorkSpace ws; public WorkSpaceViewer(WorkSpace workSpace) { ws = workSpace; } public void paint(Graphics g) { ws.draw(g); } public static void main(String[] args) { WorkSpace ws = new WorkSpace(); // TODO - YOU MUST ADD CODE HERE! // // After you implement the Drawable interface in the necessary classes // You must construct at least two object of each shape type, // Circle, Rectangle, Triangle, ConvexPolygon, and Square. One msut be // filled and the other not filled. Try differnt colors and sizes and, if // you are up to it, be creative and draw some kind of picture. Note that // the dimensions are in pixels so size accordingly. // // Here are some samples to get you started. If you have done everything // correctly this should compile, run and draw a couple of circles on your // screen - it may take a few seconds to display so be patient. Once this // works create your own shapes and demo to your instructor. // ws.add(new Circle(70, new Point(250, 250), Color.cyan, true)); ws.add(new Circle(20, new Point(250, 250), Color.black, false)); // Create an application frame setting its size and closing behavior JFrame frame = new JFrame("WorkSpace Viewer (tm)"); frame.setSize(500, 500); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Create a applet - specifically a WorkSpaceViewer Applet applet = new WorkSpaceViewer(ws); // Add the applet to the application frame frame.add(applet); // Display the application frame frame.setVisible(true); } }