// RegionStack.java // Name: // Login: // Lab section time: import java.awt.*; import java.util.*; public class RegionStack { public static boolean DEBUGGING = false; // Store a "stack" of regions, in which a Region may be moved // from the middle of the stack to the top. /** * EFFECT: Initialize an empty stack of regions. */ public RegionStack ( ) { // *** you fill this in } /** * REQUIRES: r != null. * MODIFIES: this; System.out if DEBUGGING. * EFFECT: Add a region at the top of the stack. */ public void add (Region r) { // *** you fill this in } /** * REQUIRES: x >= 0, y >= 0. * MODIFIES: this; System.out if DEBUGGING. * EFFECTS: The mouse has been clicked at position (x,y). * Find the top region on the stack (if any) that contains the * given coordinate, and move that region to the top of the stack * without disturbing the order of the other regions. * Then tell the moved region to handle the click. * If none of the regions on the stack were clicked on, just return. */ public void handleClick (int x, int y) { // *** you fill this in } /** * REQUIRES: the stack of regions is not modified while * the iterator returned is in use. * EFFECT: Return an iterator that returns regions in bottom- * to-top sequence. */ public Iterator regions ( ) { // *** you fill this in } LinkedList myRegions; }