Class EDU.gac.max.flip.Flip
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class EDU.gac.max.flip.Flip

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Window
                           |
                           +----java.awt.Frame
                                   |
                                   +----EDU.gac.max.flip.Flip

public class Flip
extends Frame
This class is the main class for an application program called Flip that is a puzzle in which the user is presented with a 6x6 grid of buttons such that clicking any one flips the color of that button and its neighbors (if any) to the north, south, east, and west. The goal is to get the buttons back to all one color.

Written 17 Aug 1996 by Max Hailperin <max@gac.edu>


Constructor Index

 o Flip()

Method Index

 o action(Event, Object)
 o flip(int)
The flip method takes care of flipping one of the "keys" on the board -- such as the one clicked-on or one of its neighbors.
 o handleEvent(Event)
 o main(String[])
 o randomize()
The randomize method independently chooses whether to flip each key with a 50/50 chance for each.
 o recolor(int)
The recolor method updates the displayed color of one of the keys on the board to reflect the current flippedness state of that key.

Constructors

 o Flip
  public Flip()

Methods

 o handleEvent
  public boolean handleEvent(Event evt)
Overrides:
handleEvent in class Component
 o action
  public boolean action(Event evt,
                        Object arg)
Overrides:
action in class Component
 o flip
  protected void flip(int key)
The flip method takes care of flipping one of the "keys" on the board -- such as the one clicked-on or one of its neighbors. This procedure is responsible both for updating the object's record of which state the key is in and also for actually recoloring the displayed key (using the recolor method).
 o recolor
  protected void recolor(int n)
The recolor method updates the displayed color of one of the keys on the board to reflect the current flippedness state of that key.
 o randomize
  protected void randomize()
The randomize method independently chooses whether to flip each key with a 50/50 chance for each. Note that for some board sizes this kind of randomization might lead to board configurations that can not be solved (to a single-color state) by any combination of mouse clicks. If such sizes are to be used, it would be better to have the randomize procedure act like the user interface does, flipping a key and its neighbors rather than just the one key.
 o main
  public static void main(String args[])

All Packages  Class Hierarchy  This Package  Previous  Next  Index