// DeleteCmd.java // Command class to perform a delete command. // Written by THC for CS 5 HW 3. Modified by Scot Drysdale import java.awt.*; public class DeleteCmd extends Command { // When the mouse is clicked, find the nearest Shape in the drawing // to the mouse position. If there is such a Shape, then // have it remove itself from the drawing. public void executeClick(Point p, Drawing dwg) { Shape s = dwg.getCloseShape(p); // find frontmost Shape containing p if (s != null) // was there a Shape containing p? dwg.remove(s); // yes, remove it from the drawing } }