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