The AppletLogic module is the central logic in a Java Educational Applet. It contans all the core data and key states in the applets. The Controller module recieves the user input and interacts with this module to send the request for updating the data and states in the central applet logic. Upon recieving of the updating requests, the AppletLogic module may do the computation and update the data itself or send the request to the Algorithm module and let the latter do the computation and update the core data in the AppletLogic module.
An important aspect is that the central logic for a given Java Educational Applet should always be consistent in the entire applet. Here we use the Singleton pattern here to ensure that the applet contains only a single instance of the AppletLogic.java class. One way use the singleton pattern is to declare all the core data and methords as static. Other classes in the applet then access the mothods of the AppletLogic through the AppletLogic class.
For example, soppose we have an AppletLogic's subclass called MyAppletLogic.java,
which contains all the core data and key states in the applet. Also soppose
we have an Algorithm subclass called MyAppletAlgorithm.java, which
contains all the methods doing the computations. Then we can have the method
in MyAppletLogic.java call a method in the MyAppletAlgorithm.java
class to do the computation and update the data and states in the AppletLogic
module.
//This method is in MyAppletLogic.java class
public static void SomeDataUpdating(){
//call the corresponding method in MyAppletAlgorithm.java class to do the computation
instanceOfMyAppletAlgorithm.ComputingSomethingAndUpdatingData();
}