Class Towers2

Class Towers2

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Panel
                           |
                           +----java.applet.Applet
                                   |
                                   +----Towers2

public class Towers2 (View complete Source)
extends Applet

Constructor Index

 o Towers2()

Method Index

 o init()
 o mouseDown(Event, int, int)
"Pick up" disk -- Figure out which tower region we are in.
 o mouseDrag(Event, int, int)
Drag disk across screen, along with the mouse cursor.
 o mouseMove(Event, int, int)
 o mouseUp(Event, int, int)
"Drop" disk -- Determine which tower's region we are in and whether or not move is valid, and then place the disk.
 o paint(Graphics)
 o update(Graphics)
Handles double-buffering.

Constructors

 o Towers2
  public Towers2()

Methods

 o init
  public void init()
Overrides:
init in class Applet
 o update
  public synchronized void update(Graphics g)
Handles double-buffering.
Overrides:
update in class Component
 o paint
  public void paint(Graphics g)
Overrides:
paint in class Component
 o mouseMove
  public boolean mouseMove(Event evt,
                           int x,
                           int y)
Overrides:
mouseMove in class Component
 o mouseDrag
  public boolean mouseDrag(Event evt,
                           int x,
                           int y)
Drag disk across screen, along with the mouse cursor.
Overrides:
mouseDrag in class Component
 o mouseDown
  public boolean mouseDown(Event evt,
                           int x,
                           int y)
"Pick up" disk -- Figure out which tower region we are in. If tower not empty, 1) Take top disk off of tower, 2) Set "From" pointer to that tower, 3) Set "Holding_Disk" flag to true, 4) Repaint the screen.
Overrides:
mouseDown in class Component
 o mouseUp
  public boolean mouseUp(Event evt,
                         int x,
                         int y)
"Drop" disk -- Determine which tower's region we are in and whether or not move is valid, and then place the disk.
Overrides:
mouseUp in class Component