|
|||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |
IComboLock
interface.
See:
Description
Interface Summary | |
---|---|
IComboLock | An interface for a combination lock object. |
Class Summary | |
---|---|
ComboLockGUI | A graphical user interface (GUI) for a combination lock. |
SampleComboLock | A sample class implementing IComboLock interface. |
The comboLock package provides a graphical user interface (GUI) for a
combination lock that uses an instance of
a student-written class implementing the
IComboLock
interface.
The GUI appears like this:
A typical main
method to run this program would be
import becker.xtras.comboLock.*; public class Main { public static void main(String[] args) { // create a new combination lock with a "combination" of 10, 20, 30 IComboLock lock = new ComboLock(10, 20, 30); ComboLockGUI gui = new ComboLockGUI(lock); } }
where ComboLock
is written by the student and implements the IComboLock
interface. Substituting
SampleComboLock
for ComboLock
in the above code will yield a working demonstration program.
This program uses the Model-View-Controller pattern. The class implementing IComboLock
is the model. It must arrange to update the views each time the model's state (that is, one of
its instance variables) changes. This can be done easily with code such as the following:
import becker.util.IView; import becker.util.ViewList; public class ComboLock implements IComboLock { private ViewList views = new ViewList(); ... public void stateChangingMethod() { ... this.views.updateViews(); } public void addView(IView aView) { this.views.addView(aView); } }
|
|||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |