import java.util.*; class Frame { private ConsoleGraphics device; //private SwingGraphics device; ArrayList shapes = new ArrayList(); /** Construct a Frame with the specified width and height. @param width - the width in pixels. @param height - the height in pixels. */ Frame(int width, int height) { device = new ConsoleGraphics(width, height); // device = new SwingGraphics(width, height); } /** Add a shape to this frame. @param shape - the shape to add. */ void add(Shape shape) { shapes.add(shape); } /** Remove a shape from this frame. @param shape - the shape to remove. @returns true if the shape was in the frame, false o/w. */ boolean remove(Shape shape) { return shapes.remove(shape); } /** Remove all shapes from this frame. */ void clear() { shapes.clear(); } /** Cause this frame to be displayed. */ void show() { for (Shape shape : shapes) { shape.draw(device); } device.render(); } }