import java.awt.Image; /** *
DoorCanvas adapts ImageCanvas for LetsMakeADealApplet. It * stores the various door Images and maintains state.
* * @author Mark L. Irons * @version 1.0 * @date 18-11-1998 */ public class DoorCanvas extends ImageCanvas { Image currentImage_ = null; Image unselectedImage_ = null; Image selectedImage_ = null; Image badImage_ = null; /** * Provided for convenience only. DoorCanvas should be initialized * by calling a constructor with parameters. */ public DoorCanvas() { } /** * Creates a DoorCanvas. * * @param handler a callback that handles events from this object * @param unselected unselected door Image * @param selected selected door Image * @param bad booby prize door Image */ public DoorCanvas(ImageCanvasEventHandler handler, Image unselected, Image selected, Image bad) { // create the ImageCanvas part super(handler,unselected); // set the Images unselectedImage_ = unselected; selectedImage_ = selected; badImage_ = bad; currentImage_ = unselectedImage_; } /** * Sets the DoorCanvas to the unselected state */ public void setUnselected() { currentImage_ = unselectedImage_; setImage(currentImage_); draw(); } /** * Sets the DoorCanvas to the selected state */ public void setSelected() { currentImage_ = selectedImage_; setImage(currentImage_); draw(); } /** * Sets the DoorCanvas to the revealed booby prize state */ public void setBad() { currentImage_ = badImage_; setImage(currentImage_); draw(); } /** * Is this door the booby prize? */ public boolean isBad() { return (currentImage_ == badImage_); } } // class DoorCanvas